#include <iostream>
using namespace std;
int main()
{
int amount, row, column, size, *ary;
bool check;
while (cin >> amount)
{
for (int k = 0; k < amount; k++)
{
cin >> column >> row;
size = column * row;
check = true;
ary = new int[size]();
for (int i = 0; i < size; i++)
cin >> ary[i];
for (int i = 0;i < size/2;i++)
if (ary[i] != ary[size - 1 - i])
{
check = false;
break;
}
delete[]ary;
if (check == true)
cout << "go forward\n";
else
cout << "keep defending\n";
}
}
}