/*
巴什游戏,水题
本题要点:
1、如果当前剩下的石头 n 是 m + 1 的倍数,甲必输。
*/
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int T, n, m;
int main()
{
scanf("%d", &T);
while(T--)
{
scanf("%d%d", &n, &m);
if(n % (m + 1) == 0)
printf("second\n");
else
printf("first\n");
}
return 0;
}
/*
2
23 2
4 3
*/
/*
first
second
*/