
Automatic set tracking for lifters on Apple Watch
Do the set.Your watch logs it.Do the next one.
Your watch notices when a set starts and ends, names the exercise and counts the reps, all on the wrist. When it is not sure of the exercise, it asks. Confirm with one tap or let it log itself. The watch does not measure weight: it carries over from your last set of that lift.




From a real workout
Waiting for the first set
Recording
- Push-up · 0/12
- Push-up · 0/5
- Push-up · 0/10
Wrist acceleration, gravity removed. Reps counted out of reps logged. No model here trained on this workout.
From wrist motion to a logged set
The watch records its motion sensors at 200 Hz for the whole workout. One neural network finds each set as it happens, a second names the exercise, and signal processing counts the reps. Below is the first set from the recording above, then each stage scored on workouts it never trained on.
Push-up, first set
12 reps counted · 12 logged · 12.1 s
Move across the set
Wrist rotation rate, 0 to 3 rad/s, smoothed for display over the raw trace. Each dot is a rep the counter placed.
- Counted
- 7of 12
- Since rep 7
- 0.40s
- Set probability
- 1.00
- Classifier confidence
- 0.95
0.76 s after rep 6
a set opens above 0.6, closes below 0.4
named the lift
Scored on workouts each model never trained on
- Sets found
- 92.7%
- Lift named, gain over a hand-built baseline
- +12.3pts
- Counted exactly
- 71.4%
91.6% precision
100% vs 87.7%, 95% CI [+4.6, +23.0]
given the set’s true start and end
How the models work, and what they still get wrong.
What it names
The watch names these lifts on its own today. The list grows as the models are retrained.
Named automatically
- Bodyweight squat
- Dumbbell biceps curl
- Dumbbell lateral raise
- Dumbbell shoulder press
- Push-up
Everything else in the catalogue
Pick the exercise from your recents or by body part when the watch asks, or add the set yourself.
:::::,,,,,,,,,,,,,:::::::::::::::::::::::::::::::::::::::::,,,,,,,,::::;;;;;;;;;;;;;;;-------~~~~~~---~~~~~~~~~~~~~~~----;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::,,,,,,,
::::,,,,,,,,,,,:,::::::::::::::::::::::::::::::::::::::::::,,,,,,,,::::;;;;;;;;;;;;;;------~~~~~~~~~~~~~~~~~~~~~~~~~~~-----;;;;;;;;;;;;;;;;;;;;;;;;:::::,,,,,...
::::,,,,,,,,,,,:::::::::::::::::::::::::::::::::::::::::::::,,,,,,,:::::;;;;;;;;;;;;;-----~~~~~~~~~~~~~~~~~~~~~~~~~~~~-----;;;;;;--;;;;;;;;;;;;;;;:::::,,,,,,,..
:::::,,,,,,,,,,:::::::::;;;;;;;:::::::::::::::::::::::::::::,,,,,,,:::::::;;;;;;;;;;;;----~~~~~~~~~~~~~~~~~~~~~~++~~~~------;;;;;;;;;;;;;;;;;;;;;;::::,,,,,,.,,,
:::::,,,,,..,,,:::::::;;;;;;;;;;:::::::::::::::::::::::::::,,,,,,,,::::::::::;:;;;;;;;-----~~~~~~~~~~~~~~~~~~~~~+~~~~~~-----;;;;;;;;;;;;;;;;;;;;;::::,,,,,,,.,,,
:::::,,,,,..,,,:::::::;;;;;;;;;;;::::::::::::::::::::::::::,,,,,,,,,:::::::::::;;;;;;;------~~~~~~~~~~~~~~~~~~~~~~~~~~~---;;;;;;;;;;;;;;;;;;;;;;::::,,,,,,...,,,
:::::,,,,,.,,,,,:::::;;;;;;;;;;;;::::::::::::::::::::::::::,,,,,,,,,,:::::::::::;;;;;;;----------~~~~~~~~~~~~~~~~~~~~~---;;;;;;;;;;;;;;;;;;;;::::::,,,,,,,,...,,
::::::,,,,,,,,,:::::;;;;;;;;;;;;;::::::::::,,,:::::::::::::,,,,,,,,,,,,::::::::::;;;;;;;;;--------~~~~~~~~~~~~~~~~~~~---;;;;;;;;;;;;;;;;;;;;;::::::,,,,,,,,,,..,
::::::,,,,,,,,,::::;;;;;;;;;;;;:::::::::::,,,,,:::::::::::,,,,,,,,,,,,,,:::::::::;;;;;;;;;;---;;-------~~~~~~~~~------;;;;;;;;;;;;;;;;;;;;;;::::::,,,,,,,,,,,...
::::::,,,,,,,,,::::;;;;;;;;;;;;::::::::::,,,,,,:::::::::::,,,,,,,,,,,,,,,:::::::::;;;;;;;;;;;;;;;;-------~~~~~------;;;;;;;;;;;;;;;;;;;;;;;;::::::,,,,,,,,,,,,..
::::::,,,,,,,,,::::;;;;;;;;;;;:::::::::,,,,,,,,,:::::::::,,,,,,,,,,,,,,,::::::::::;;;;;;;;;;;;;;;;;;;-------------;;;;;;;;;;;;;;;;;;;;;;;;;;:::::,,,,,,,,,,,,.,,
::::::::,,,,,,::::::;;;;;;;;;::::::::::,,,,,.,,,,:::::::,,,,,,,,,.,,,,,:::::::::::;;;;;;;;;;;;;;;;;;;;;---------;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::,,,,,,,,,,,,,,,
::::::::,,,,,,::::::;;;;;;;;;:::::::::,,,,,...,,,,::::::,,,,,,,,,,,,,,,:::::::::::;;;;;;;;;;;;::;;;;;;;;-----;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::,,,,,,,,,.,,,,,
:::::::::,,,,::::::;;;;;;;;;;:::::::::,,,,,...,,,,:::::,,,,,,.,,,,,,,,,::::::::::;;;;;;;;;;;::::::;;;;;;;---;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::::,,,,,,,,,,,,,,,,
::::::::::,,:::::::;;;;;;;;;:::::::::,,,,,,..,,,,,,:::,,,,,,.,,,,,,,,::::::::::::;;;;;;;;;;;::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::::::,,,,,,,,,,,,,,,,
:::::::::::::::::::;;;;;;;;;:::::::::,,,,,,,.,,,,,,,,,,,,,,,,,,,,,,,:::::::::::::;;;;;;;;;;:::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::::::,,,,,,,,,,,,,,,,
:::::::::::::::::::;;;;;;;;::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::::::::::;::;;;;;;;;;::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::::,,,,,,,,,,,,,,,,,,,
,::::::::::::::::::;;;;;;;;::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::::::;;;;:;;;;;;;;::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::,,,,,,,,,,,,,,,,,,,,
,,:::::::::::::::::;;;;;;;:::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::;;;;;;;;;;;;;;;;;::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::,,,,,,,,,,,,,,,,,,,,,
,,,::::::::::::::::;;;;;;::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::::;;;;;;;;;;;;;;;;;::::::::::::;;;;;;;;--;;;;;;;;;;;;;;;;;;;;;:::::::,,,,,,,,,,,,,,,,,,,,,,
,,,,,:::::::::::::::;;;;::::::::::,,,:,,:,,,,::,,,,,,,,,.,,,,,,,,::::::;;;;;;;;;;;;;;;;;:::::::::::::;;;;;;--------;;;;;;;;;;;;;;;;;:::::,,,,,,,,,,,,,::,,,,,,,,
..,,,::::::::::::::::::::::::::,,,,,,,,,::,,::::,,,,,,,.......,,,:::::;;;;;;;;;;;;;;;;;::::::::::::::;;;;;----------;;;;;;;;;;;;;;;:::::,,,,,,,,,,,,::::,,,,,,,:
..,,,::::::::::::::::::::::::::,,,,,,,,,::::::::,,,,,,,.......,,,:::::;;;;;;;;;;;;;;;;:::::::::::::::;;;;;;---------;;;;;;;;;;;;;;;::::,,,,,,,,,,,,,:::,,,,,,,::
..,,,::::::::::::::::::::::::::::::::::::::,::::,,,,,,,......,,,,::::;;;;;;;;;;;;;;;;;::::::::::::::::;;;;;;;-----;;;;;;;;;;;;;;;;;::::,,,,.,,,,,,,::::,,,,,,:::
,,,,::::::::::::::::::::::::::::::::::::,,,,::::::,,,,,....,,,,,::::;;;;;;;;;;;;;;;;::::::::::::::::::;;;;;;;;;-;;;;;;;;;;;;;;;;;;;::::,,,,...,,,,,:::::,,,,,:::
,,,:::::::,,,,,::::::::::::::::::::,,::,,,,,,:::::::::,,,,.,,,,,::::;;;;;;;;;;;;;;;::::::::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::,,,....,,,,,::::,,,,:::::
,,,,,,,,,,...,,,,::,,..,,,,,,,,,,,,,,::,,,,,,,:,,,:::::::::::,,,:::;;;;;;;;;;;;;;;::::::::::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;:::::,,,.....,,,,::::,,,,:::::
.............,,,,,,. ..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::;;;;--;;-~~~~--;:::::::::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;::::,,,,...,,,,:::::,,,,:::::
...........,,,,,,.. ..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::::::::;~+***=+~~~~~~~--;;:::::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;::::,,,,,,,,,,,:::::,,,,:::::
..........,,,,,,. ...,,,,,,,,,,,,,,,,,,,,::,,,,,,,,,,,,,,,::,::::-;~+=**%%*+~--~~~~~--;;:::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;::::,,,,,,,,,,::::,:,,,,:::::
.........,,,,,.. .....,,,,,,,,,,,,,,,,,,::,.,,,,,,,,,,,,,,,,,,,:::--~~++**%%%=~--~~~~~-;,..:::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;::::,,,,,,:::::,,,,,,,::::::
.............. .......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...:.;--~~~~~~+=**%%*=~--~~: .::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::::::::,,,,,,,::::::
............. ........,,,,,,,,,,,,,,,,,,,.,,,,,,,,,,,,,....,.:;--~~~~~~~~~++=*%%%*-:, ,::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::::::::,,,,,,,::::::
............ .......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.......,.;-----~~~~~~~~~-~~+*%%~.. .:::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::::::::,,,,,,,::::::
........... .....,,,,,,,,,,,,,,,,,.,,,,,,,,,,,......,.:;-----~~~~~~~--;;:::+*+,,,,,,::::::;;;;;;;;--~~~--;;;;;;;;;;;;;;;;;;;;:::::::::,,,,,,::::::
..,...... ....,,,,,,,,,,,,,,,,,,,,,,,,..,........,.;------~~~----;;::,. -=~, +%%%%%**==+++=**%%@@@@@@@%%*+~-;;;;;;;;;;;;;;::::::::,,,,,,,::::::
.,:..,.. .......,,,,,,,,,,,,,,,,,,,,.............,;----------;;;::,.. ~=-. *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*+-;;;;;;;;;;;::::::::,,,,,,::::::
.,,,,.. ........,,,,,,,,,,,,,,,,............., :;-------;;;:::,.. ,++;..%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+-;;;;;;;;;:::::::,,,,,:::::::
.,,,. .. ...........,,,,,,,,,,,,............. ...;;------;;:::,... -+-;.:%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*=+~-;;;;::::,,,,,,:::::::
.... .. .............,,,,,,,............. .. . :;;;--;;;:::,... .++-..~%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%~::,,,:::::::::
............,,,,,,,........... ...:;;;;;;;::,... ;+~-*-+%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%;::::::::::::
...........,,,,,,........... . ,:;;;;:::,... ++-~@-;%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%~:::::::::::
........,,,,,,........... ..:::::::,,.. :+~: -.;*%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+::::::::::
........,,,,,,........... . .:::::,,... ~+-, ,.~*%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%~:::::::,,
.....,............... . ,,:,,,... ,++;. ..=*%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%+::::::,,
................ ..,,.... ~+~:. ,~**%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%+::::,,,
. ...... . ...... .++-...;+*%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%~:::,,,
....... . .... ;+~;..,-=*%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%*%;::,,.
........ ++-,..;+*%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%*%=:,,,.
...... :+~;:,:~=*%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%*****%*%%~,,,.
... . ~+-:: ;=*%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*=+==***%%;,,.
.. :+~;.:.~=*%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*++++=**%%*:,.
-+~::.:+**%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*++++=***%=,.
. .++-.: ~=**%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*=+++=***%%~.
;+-;,.,+=**%%%%%%%%@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+~~++=***%%;
.~+~,. ;=**%%%%%%%%@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=~~~++=**%%*
;+--. .~=**%%%%%%%%@%@@@@@@%@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*~~~~++=**%%
.;~-,. ;+=******%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=~~~++==***
,;. .-+*********%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*+-~~++==**
,. :~+=*********%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%@@@%%%%**--~~++=**
.;~~+=**********%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*****%%%%%%*+;~~~+==*
,;--~+=***********%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*==++=*******~-~~+++=
.,;;;-~++==******=**%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%**=+++++=****=;-~~+++
..:;;;;;~~++=*****=***%%%%%%@%@@@@@@@@@@@@@@@@@@@@@@@@@@%%**++~~~++==**-;-~~++
..,::;;;;;-~++=*****=****%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@%%*=+~--~~+=**=:;-~~+
...,:::::;;;;-~+=****==******%%%%%%%%%@@@@@@@@@@@@@@@@@@@%@%%%*+~-;;-~+=**~:-~~+
..,,::::::;:;;-~++=======******%%%%%%%%%@@@@@@@@@@@@@@@@@@%@%%*=~-;;;-~+=**;;-~~
.,::::::::;:;;;-~~+===++===************%%%%%%@@@@@@@@@@@@@@%@%%*+~-;;;-~+***;--~
..,::::::::;;:;;--~~++++++===****************%%%%@@@@@@@@@@@%%@%*+~~-;;-~+=***--~
.,:::::::::;:;;;;-~~++++++====*******==******%%%%@%%@@@@@@@@%%%*+~~-;;--~+***=-~
..,::::::::;:::;;;-~~~++++===************===***%%%%@@@@@@@@@%%%%*~-~-;--~+=****~
..,,::::::::::;;;-~~~++++===************=====****%%@@@@@@@@%%%%*+;;----~~+==***
.,,,,,:::::::;;;;-~~~~~++===*****%****===+++=====*%%@@@%%@%%%***~;;;;--~~+=***
..,,,,:::::::;;;-~~~~~++===*****%****==+++++++++++**%%%%%%%%***=;;;;;-~~++=**
..,,,,:,:::::;;--~~~~~++++=*****%****=+++~~~~~~~--~+=***%**%****~:;;;-~~++=**
..,,,::,::::;;;;~~~~~++++=***%%%%***=+++~~-----;;;-~~+=*********;;;;;-~~++==
... ...,,,,::::;;;--~~~~++++=*****%%%**=+++~~---;;;;;---~~+=====***=;;;;--~+++=
,;;:,. ...,,,,:::;;;--~~~++++++=****%%%**==+++~---;;;;;;--;-~~++++=***+;;--~~~+++
.;;;;;:.. ....,,,:::;;--~~++++++++==****%**===+++~--;;;;;;;;;;;;-~~~+=***=---~~~~~+
.:;;;;;;::,..,. ....,,::::;--~~~++++~~~+++=*******===++~~--;;::::::::;;;-~+****=;--~~~~~
,.. .:;;;;;;;;::::, ......,:::;;;---~~~~~~--~+==***%*****==++~~-;::::::::::;;~+=****=;----~~
;;::,.. .:;;;;;;;::::,,, .....,,,:::;;;-;-~~~----~+=**%%%%%%****=++~-;;:::::::::;-~+=****=-----~
~~--;;:::, .:;;;;;;:::::,,,. ......,,::::;;;-~~~~~~~~+=**%%%%%%%%***==+~-;;::::::::;;-~+=****=---~~
~~~~~~~--;: ,:;;;;;;;::::,,,,. ......,,::::;;;~~~~~~~~~+=*%%%%%%%%%%***=+~--;;;;:::::;;~~+=***%*~~~~
~~~~~~~~~~-. .:;;;;;;;;:::::,,,, ....,,::::;;;;-~~~+~~~-~=*%%%%%@@@%%%**=+~~;;;;;;;;:;;-~++=***%*+~~
~~~~~~~~~~~: ,;;;;;;;;;;;:::::,,. .....,,:::::;;-~~~~+~~~-+*%%%%@@@@@%%%**=+~--;;;;;;:;;-~++=****%*~~
~~~~~~~~~~~-. .:;-;;;;;;;;;;:::::::. ....,,:::::;;-~~+++++~-+*%%%%@@@@@%%%*==+~~-;;;;;;;;;-~+==****%%+
~~~~~~~~~~~~; .;---------;;;;;;;::::. ....,::::::;;-~++++++~-+**%%%%@@@@%%***=+~~;:;;;;;;;-~++==****%*
~~~~~~~~~~~~-:. ,;-----------;;;;;;;;;:. ....,,,::::;-~~++++++~~+*%%%@@@@@%%%***=+~;,:;;;;;;-~~++===****
~~~~~~~~~~~~~~;::,,,.... .:-~~~~~~~~--------;;;;;: ....,,,:::;;-~~+++==+~~=*%%@@@@@@%%%%***=~,,:;;;;;;-~~+++===**
~~~~~~~~~~~~~~~~------;;;;;;::,,.. ,;~~~~~~~~~~~~~~~------;;, ....,,,,:::;-~~++=*=+++=*%%@@@@@@%%%%***=;.:;;;;;;--~~~++==**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~---;;:,. .:~~~~~~~~~~~~~~~~~~~-~---;. .....,,,,,::;-~~+=***=++=*%%@@@@@%%%%%****;.:;;;;;;---~~++==*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-;:,. ,-~~~~~~~~+~~~~~~~~~~~~~~--;. .....,,,,::;-~~+=***=++=*%%@@@@%%%%%%%%%*~,:;;;;;;;---~++==
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-;;:.. .;~~~~~~++++++++++++~~~~~~~~~: ......,,,:;;-~+==*=+++=*%%@@@%%%%%%%%%%*=;::;;;;;-~~~~+++
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-;:,,.. .;~++++++++++++++++++++++~~~~~-. .......,::;-~~++=+~~++**%%%%%%%%%%%%%%%*-,::;;;--~~~~+~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~---;;:,,... .:~++++++++++++++++++++++++++~~~- .....,,:;;--~+++~~~+=***%%%%**%%%%%%%*+:,:;;;-~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~---;:::;~+++++++++++++++++++++++++++++~~: ...,,::;;;~~~~-;-~+===*******%%**%%%*~::;;---~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++~~~~++++++++++++++++++++++++++++++++~~. ...,,:::;----;;-~~++====****%**%%%%%*;::;--~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++++++; .....,,::;;;;;;;--~~+++=*******%%%%%%+:;--~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++++++++++++++++++++++++++++++~. ......,:::;;::;;;-~~~+==******%%%%%%*+--~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++++++++++++++++++++++++++++++- ......,,::::::;;;--~+===*****%%%%%%%%*+~-;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++++++~: .. .....,,,::::::;;-~~+++=*****%%%%%%%%%*+:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++++++++++++++++++++++++++++~..... ....,,,:::;;---~~~++=******%%%%%%%%%=
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++++; ..... ....,,,::;------~~++===*****%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++++~,....... ......,,:;;;;;;--~~~++==*******%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++-...,,,,.. ......,::;;;;;;;---~++===*********%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++++++++++++++++++++++++++++++++++++++++++:..,,:,,.... ........,,:::::;;;--~++++======****::,,,,,,,:::::::::::::::::::::,,,::;;;;;;;;---~~~~~~~~~~~~~--;;;;;;;;;;;;;::,,,,
::,,,,,,:::::;;:::::::::::::::,,,:::;;;;;;;--~~~~~~~~~~~~~~---;;;;;;;;;;;::,,,,.
:::,,.,,:::;;;;;::::::::::::::,,,,:::::;;;;---~~~~~~~~~~~~~---;;;;;;;;;;::,,,..,
:::,,,,,::;;;;;;;::::::::::::,,,,,,:::::;;;;-----~~~~~~~~~~-;;;;;;;;;;:::,,,,,.,
:::,,,,,::;;;;;:::::,,,,:::::,,,,,,,:::::;;;;;;;;---~~~----;;;;;;;;;;;:::,,,,,,.
::::,,,:::;;;;;::::,,,,,::::,,,,,,,,:::::;;;;;;;;;;-----;;;;;;;;;;;;;::::,,,,,,,
::::,,,:::;;;;:::::,,..,,:::,,,,,,,::::::;;;;;:::;;;;-;;;;;;;;;;;;;:::::,,,,,,,,
:::::,::::;;;;::::,,,,.,,,,,,,.,,,:::::::;;;;;::::;;;;;;;;;;;;;;;:::::::,,,,,,,,
:::::::::;;;;;::::,,,,,,,,,,,,,,,:::::;;;;;;;:::::;;;;;;;;;;;;;;;:::::,,,,,,,,,,
,::::::::;;;;:::::,,,,,,,,,,,,,,,:::;;;;;;;;::::::;;;;;;;;;;;;;;;;:::,,,,,,,,,,,
,,::::::::::::::,,,,:,::,,,,..,,,::;;;;;;;;;::::::;;;-----;;;;;;;;::,,,,,,,:,,,:
.,,:::::::::::::::::::::,,,,..,,:::;;;;;;;;::::::::;;;---;;;;;;;;:::,,,,,,::,,,:
,,:::::::::::::::::,,,::::,,,,,,::;;;;;;;:::::::::::;;;;;;;;;;;;;::,,..,,:::,,::
.,.....,,,..,,,,,,,,,,,,,,::::::::;;-;-~-;::::::::::;;;;;;;;;;;;;::,,..,,::,,:::
.....,,,. ..,,,,,,,,,,,,,,,,,,:::;~=**=+~~-;;:::::::;;;;;;;;;;;;;::,,,,,::,,:::
.....,. ....,,,,,,,,,,,,,,,,,,,,;-~~+***+~-, ,::::;;;;;;;;;;;;;:::::::,,,,:::
...... ...,,,,,,,,,,,,,,,,..,:--~~~~~~+*+. :::;;;;;;;;;;;;;;;:::::::,,,:::
..... ...,,,,,,,,,,,,,.....;--~~--;:.;+.+**==+=**%%%%*+~;;;;;;;::::,,,:::
.,.. ....,,,,,,,,,......,----;;:,. -~.%@@@@@@@@@@@@@@@%*+-;;;::::,,,:::
.. . ......,,,,.........:;-;;:,. +;:%@@@@@@@@@@@@@@@@@@@@%%%%=:,,::::
......,,,..... ..;;;:,. ;~*-%@@@@@@@@@@@@@@@@@@@@@@@@@%-:::::
....,,,..... .,::,. +;.:*%@@@@@@@@@@@@@@@@@@@@@@@@@%-:::,
........ .,.. :+,.+%%@@@@@@@@@@@@@@@@@@@@@@@@@%%-::,
... . ~-.;*%@@@@@@@@@@@@@@@@@@@@@@@@@@%%*;,,
... ,+:,+*%@@@@@@@@@@@@@@@@@@@@@@@@%****=,,
. -~,;*%%@@@@@@@@@@@@@@@@@@@@@@@@%*+=*%+,
.+;,+*%%%@@@@@@@@@@@@@@@@@@@@@@@@%++=*%;
;~,:=*%%%@@@@@@@@@@@@@@@@@@@@@@@@@+~+=**
;; ~****%%@@@@@@@@@@@@@@@@@@@@@@@@*~~+**
...~=****%%@@@@@@@@@@@@@@@@@%%%@%%%+-+=*
:-+=*****%%@@@@@@@@@@@@@@@%*=+=***~~+=
.:;;~+*****%%%@@@@@@@@@@@@@@%*+~~+*=;~+
.,:::;-~=*==***%%%%@@@@@@@@@@%%=~;~+*~-~
.::::;;-~+=+=*******%%%@@@@@@@@*+-;~=*-~
.::::;:;-~+++==********%%%@@@@%%+~;-+**~
,::::::;-~++==*****===**%@@@@%%*;--~+**
.,,,:::;-~~++=*****=+++++=*%%%**~;;-~=*
.,,,::;;~~~+=**%**=+~--;;~+=****;;-~+=
:;,. ..,,:;-~~+++=**%*=+~-;;;;;-~++**--~++
,;;;:,,. ..,::;-~~~~~+=***==+~;;::::;~=**--~~
;;:.. ,;;;:::, ..,::;;-~~-~=*%%%**=+-;::::;~=**~-~
~~~~-, :;;;:::,. ..,:::;-~~~~=%%%%%**+-;;;::-+=**+~
~~~~~- ,;;;;;::::. ..,:::;~~+~~*%%@@%%=+-;;;;;~+***+
~~~~~~: :----;;;;::. ..,,:;;~+++~*%%@@%**+-:;;;~+=***
~~~~~~~-:::,,,.. .;~~~~~---;;;. ..,,:;-~+=++*%@@@%%*+,:;;-~++=*
~~~~~~~~~~~~~~~~--;,. :~~~~~~~~~~~-; ...,,:-+=*++*@@@%%%*=:;;;--~+=
~~~~~~~~~~~~~~~~~~~~~-:.. .~~~+++++++~~~~: ...,:;~+=++*%%%%%%%*-:;;-~~+
~~~~~~~~~~~~~~~~~~~~~~~~~-;;:,.,-+++++++++++++~~. ...:;-~~~~=**%*%%%*+:;--~~
~~~~~~~~~~~~~~~~~~~~~~++++++++~+++++++++++++++++; ..::;-;-~+==***%%*~;-~~
~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++++, ...,:::;;-~=***%%%*+~-
~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++~.. ...,:::;-~+=**%%%%%+
~~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++++;... ...,;---~++=***%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~+++++++++++++++++++++++~.,,,.. ...,::;;-~+===***