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

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<iostream>
#include<set>
#include<stdlib.h>
#include<vector>
using namespace std;
const int maxn=1e5+10;
const int inf=0x3f3f3f3f;
int gcd(int a,int b){
	if(a%b==0)return b;
	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");
		}
	}
	
}