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

#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;
const int maxn=1e5+9;
const int inf=0x3f3f3f3f;
typedef long long ll;
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=q;i++){
    	int a,b;
    	scanf("%d%d",&a,&b);
    	if(__gcd(a,b)>2) printf("2\n");
    	else printf("%d\n",__gcd(a,b));
	}
	return 0;
}