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: 78ms
Memory: 1712kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=10100;
typedef long long ll;
int gcd(int a,int b){
	if(b!=0)
		return gcd(b,a%b);
	return a;
}
int main(){
	int n,q;
	scanf("%d %d",&n,&q);
	while(q--){
		int s,t;
		scanf("%d %d",&s,&t);
		int temp=gcd(s,t);
		if(temp!=1)
			printf("2\n");
		else
			printf("1\n");
	}
	return 0;
}