#include #include #include #include #include using namespace std; const int maxn = 500010, inf = 1e9 + 233; int p[110][110]; int live[110]; int n, x; template inline void read(T &k) { int f = 1; k = 0; char c = getchar(); while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar(); while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar(); k *= f; } void solve() { read(n); int lr = 0; for (int i = 1; i <= n; i++) read(x), live[i] = 1, (x) && (lr = i); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) read(p[i][j]); int dead = 0; for (int i = 1; i <= n; i++) if (live[p[lr][i]]) { live[p[lr][i]] = 0; dead = p[lr][i]; break; } // printf("lr:%d dead:%d\n", lr, dead); int cnt = n - 1; while (1) { if (!live[lr]) { puts("lieren"); return; } else { if (cnt <= 2) { puts("langren"); return; } } for (int i = 1; i <= n; i++) if (live[p[dead][i]]) { live[p[dead][i]] = 0; dead = p[dead][i]; break; } cnt--; } } int main() { int T; read(T); while (T--) solve(); }