Result: Accepted
Time: 76ms
Memory: 1712kB
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int gcd(int a,int b)
{
if(b == 0)
return a;
return gcd(b,a % b);
}
int main()
{
int n,q;
scanf("%d %d",&n,&q);
while(q--)
{
int s,t;
scanf("%d %d",&s,&t);
if(gcd(s,t) == 1)
printf("1\n");
else
printf("2\n");
}
}