#include #include #include #include using namespace std; const int MAXN = 55; deque a[MAXN]; bool vis[MAXN]; int iden[MAXN]; int n; int main() { int t; scanf("%d",&t); while(t--) { scanf("%d",&n); int idx = 0; for(int i = 1;i <= n;i++) { scanf("%d",&iden[i]); if(iden[i] == 1) idx = i; } for(int i = 1;i <= n;i++) { a[i].clear(); for(int j = 1;j <= n;j++) { int x; scanf("%d",&x); a[i].push_back(x); } } int cnt = n;//在场人数 memset(vis,0,sizeof vis); int f = 0; int now = 0;//现在杀死人的下标 while(a[idx].size() && vis[a[idx].front()]) a[idx].pop_front(); now = a[idx].front();//狼人刀的 if(now == idx) { puts("lieren"); continue; } vis[now] = 1;cnt -= 1; while(cnt > 2) { while(a[now].size() && vis[a[now].front()]) a[now].pop_front(); if(a[now].size()) { int cur = a[now].front(); a[now].pop_front(); if(cur == idx)//杀的是狼 {//直接赢 f = 1; break; }else { cnt -= 1; } now = cur;//变成这个人判定了 vis[cur] = 1; } } if(f) puts("lieren"); else puts("langren"); } return 0; }