#include <bits/stdc++.h> //reverse(d.begin(),d.end());
using namespace std;
int main()
{
int a,x,y;
while(cin>>a)
{
for(int k=0;k<a;k++)
{
string b,c,d;
b.clear();
c.clear();
cin>>x>>y;
for(int i=0;i<x*y;i++)
{
cin>>c;
b=b+c;
}
d=b;
reverse(d.begin(),d.end());
if(b==d)
{
cout<<"go forward"<<endl;
//cout<<b<<endl<<d<<endl;
}
else
{
cout<<"keep defending"<<endl;
}
}
}
}