note memory limit problem low othersyou vertical strip n cell number consecutively 1 n bottomyou token initially place cell n you token arrive cell 1let token cell x 1 moment one shift token follow kind Subtraction choose integer y 1 x1 inclusive token cell x cell x y Floored division choose integer z 2 x inclusive token cell x cell lfloor fracxz rfloor x divide z rounded Find number way token cell n cell 1 shift print modulo m note way token cell shift way consider distinct check example explanation well understanding