Gcd Queries jan challenge15

I have submitted the code for GCDQ but getting wrong answer while i am getting correct answer for the test case.
My question is that should i print the answer after scanning each l and r value or first i should scan all l and r value and then print the answer for each value.please help me someone.thanks.

you have to print the output simultaneously,that is after each l and r value.

The thing doesn’t make any difference. The output of your code is saved in a file and matched against the correct output file of the admin.