Help me in solving GCDLM problem

My issue

can’t get the second test case

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
	public static void main (String[] args) throws java.lang.Exception
		// your code goes here

Problem Link: GCDLM Problem - CodeChef

I wonder how you cleared the first test case with that code.

Anyways, find the detailed explanation by the problem setters(editorial) here.