#include using namespace std; int id[55], rk[55][55], lr; bool isdead[55]; int main() { int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", id + i); if (id[i]) lr = i; isdead[i] = false; } int dead; for (int i = 1; i <= n; ++i) { if (i == lr) { scanf("%d", &dead); for (int j = 1; j < n; ++j) scanf("%*d"); } else { for (int j = 1; j <= n; ++j) scanf("%d", rk[i] + j); } } int alive = n; for (;;) { isdead[dead] = true; if (dead == lr) { puts("lieren"); break; } else { --alive; if (alive <= 2) { puts("langren"); break; } for (int i = 1; i <= n; ++i) if (!isdead[rk[dead][i]]) { dead = rk[dead][i]; break; } } } } }