Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 102ms
Memory: 2988kB
In contest: 1276

#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define dep(i,x,y) for(int i=y;i>=x;--i)
using namespace std;
typedef long long ll;
//struct node{
//	int 
//}p[];
//bool cmp(node a,node b)
//{
//	return ;
//}
int n,m,k,x,y,q,a[301010];
char s[101010];
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%d%d",&n,&m);
	rep(i,1,m)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",min(2,gcd(x,y)));
	}
}