#include #include #include using namespace std; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-9; int main() { int i, j, T; cin >> T; while (T--) { int n, w, last_dead; int wolf[51], kill[51][51]; int dead[51] = {0}; cin >> n; for (i=1;i<=n;i++) { cin >> wolf[i]; if(wolf[i]==1) w = i; } for (i=1;i<=n;i++) { for (j=1;j<=n;j++) { cin >> kill[i][j]; } } // langren last_dead = kill[w][1]; dead[last_dead] = 1; while(1) { if(last_dead==w) { cout << "lieren" << endl; break; } else { int sum = accumulate(dead, dead + 51, 0); if (n-sum<=2) { cout << "langren" << endl; break; } else for (i=1;i<=n;i++) { if (dead[kill[last_dead][i]]==0) { last_dead = kill[last_dead][i]; dead[last_dead] = 1; break; } } } } } return 0; }