Help me in solving ASM120 problem

My issue

The normal approach for this question exceed time limit I see people using gcd in why so?

My code

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

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		while(t-- > 0){
		    int x = input.nextInt();
		    int y = input.nextInt();
		    
		    System.out.println(y);
		}
	}
}

Problem Link: Sub or Swp Practice Coding Problem

@sahilbeniwal
plzz refer my c++ code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
    int t;
    cin>>t;
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        while(x!=0)
        {
            if(x>y)
            swap(x,y);
            int x1=x;
            x=y%x;
            y=x1;
        }
        cout<<y<<endl;
    }
}

Can you please tell why you did y%x instead of y-x

@sahilbeniwal
cozz when u do - operation it will increase time complexity and give u tle.
just think of case when Y=1000000000 and X = 1;