#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int a,row,col;
cin >> a;
while (a--)
{
while (cin >> row >> col)
{
vector<vector<int>> arr(row, vector<int>(col)), arr2(row, vector<int>(col));
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
cin >> arr[i][j];
arr2[row - i - 1][col - j - 1] = arr[i][j];
}
}
bool flag = false;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
if (arr[i][j] != arr2[i][j])
{
flag = true;
break;
}
}
}
cout << (flag ? "keep defending" : "go forward") << endl;
}
}
return 0;
}