思路:显然,n=m+1时是必败态,可以推得n是m+1的倍数的时候,都是必败态。这就是经典的巴什博弈。
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <memory.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctype.h>
#define ll long long
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
if(n%(m+1)==0){
cout<<"second"<<endl;
}else{
cout<<"first"<<endl;
}
}
return 0;
}