Help needed in CSES Problemset : Problem Exponentiation II
Problem
Solution
I don't understand line 24. Why M-1 is used instead of M? Please help me to understand. Thanks in advance.