#include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef long long ll; const int maxn = 50 + 7; int T; int n; int a[maxn][maxn]; int vis[maxn],pos,isd[maxn]; int nowp[maxn]; int main() { scanf("%d",&T); while(T--){ scanf("%d",&n); //memset(vis) for(int i = 1; i <= n; i ++){ scanf("%d",&vis[i]); if(vis[i] == 1) pos = i; isd[i] = 1; nowp[i] = 1; } for(int i = 1; i <= n; i ++){ for(int j = 1; j <= n; j ++){ scanf("%d",&a[i][j]); } } int cnt1 = 1, cnt2 = n - 1; while(cnt1 && cnt2 > 1){ while(isd[a[pos][nowp[pos]]] == 0){ nowp[pos]++; } int x = a[pos][nowp[pos]]; nowp[pos]++; if(vis[x]) cnt1--; else cnt2 --; isd[x] = 0; pos = x; } if(cnt1 == 0) printf ("lieren\n"); else printf ("langren\n"); } return 0; }