#include<iostream>
using namespace std;
int main()
{
int t,length,width;
cin>>t;
for(int i=1;i<=t;i++)
{
bool equal=true;
cin>>length>>width;
int reg[length][width];
for(int n=0;n<=length-1;n++)
for(int m=0;m<=width-1;m++)
cin>>reg[n][m];
for(int n=0;n<=length-1;n++)
{
for(int m=0;m<=width-1;m++)
{
if(reg[n][m]!=reg[length-1-n][width-1-m])
{
equal=false;
break;
}
}
}
if(equal==true)
cout<<"go forward"<<endl;
else
cout<<"keep defending"<<endl;
}
return 0;
}