A board game called Expo is played on a circular board with N cells numbered 1 to N. Cell N is followed by cell 1 again, so a token that passes the end keeps going from the start.
A player rolls a die, reads the number S on the top face and moves the token one cell forward expo(S) times, where
expo(S)=S(S−1)(S−2)⋯21
So expo(1)=1, expo(2)=21=2, expo(3)=321=9 and expo(4)=49=262144. A player starts on cell 1 and wins by standing exactly on cell N once a move is complete. Passing cell N in the middle of a move does not count.
Brad and Pete are playing this game. Once S grows even a little, moving the token expo(S) times takes longer than a lifetime. Their grandfathers never finished the game they started in their youth the traditional way, so the two of them play on their behalf. Given the number S on the die and the cell M the token stands on, report the cell the token stands on when the move is finished.