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

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int gcd(int x,int y){
	if(x%y==0){
		return min(x,y);
	}
	else{
		gcd(y,x%y);
	}
}

int n,k;
int a,b;

int main(){
	scanf("%d %d",&n,&k);
	while(k--){
		scanf("%d %d",&a,&b);
		if(gcd(a,b)==1)
		printf("1");
		else
		printf("2");
		if(k)printf("\n");
	}
}