#include #include int live[55]; int st[55]; int tab[55][55]; void solve() { int n; int id; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &st[i]); if (st[i]) id = i; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &tab[i][j]); } } for (int i = 0; i < 55; i++) live[i] = 1; int num = n; live[tab[id][1]] = 0; num--; if (id == tab[id][1]) { puts("lieren"); return; } id = tab[id][1]; while (1) { if (num <= 2) { puts("langren"); return; } int tar = 1; while (1) { if (tab[id][tar] != id && live[tab[id][tar]]) break; tar++; } live[tab[id][tar]] = 0; num--; if (st[tab[id][tar]]) { puts("lieren"); return; } id = tab[id][tar]; } } int main() { int T; scanf("%d", &T); while (T--) solve(); return 0; }