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: 77ms
Memory: 1716kB
In contest: 1276

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
#define ll long long

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a; 
}

int main()
{
/*	for(int i=1;i<=10;i++)
	{
		for(int j=i+1;j<=10;j++)
		{
			cout<<i<<" "<<j<<" "<< gcd(j,i) <<endl;
		}
	}*/
	int n,q;
	scanf("%d %d",&n,&q);
	for(int i=1;i<=q;i++)
	{
		int s,e;
		scanf("%d %d",&s,&e);
		if(gcd(max(s,e),min(s,e))==1)	printf("1\n");
		else printf("2\n");
	}
}