Help me in solving ASM120 problem

My issue

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

int main() {
int t;
cin>>t;
while(t–){
int x,y;
cin>>x>>y;
if(x%y==0){
cout<<y<<endl;
}
else if(y%x==0){
cout<<x<<endl;
}
else{
if(x%2==0 && y%2==0){
cout<<2<<endl;
}
else{
cout<<1<<endl;
}
}
}
}
I am unable to find error in this code for the respective ques .

My code

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

int main() {
    int t;
    cin>>t;
    while(t--){
        int x,y;
        cin>>x>>y;
        if(x%y==0){
            cout<<y<<endl;
        }
        else if(y%x==0){
            cout<<x<<endl;
        }
        else{
            if(x%2==0 && y%2==0){
                cout<<2<<endl;
            }
            else{
                cout<<1<<endl;
            }
        }
    }
}

Problem Link: Sub or Swp Practice Coding Problem - CodeChef

@harshita_515
plzz refer my c++ code for better understanding of the logic

#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;
    }
}