Modular GCD

This is my solution for the above problem.I am not understanding why it is giving me WA. Can anyone please help?

In ans4 u made mistake as (a-b)%m gives error
If a-b<0 then u should add mod to it as well
U can do it like this
Hope it helps :smile:

Its also giving Wrong answer.