#include using namespace std; const int maxn = 55; int id[maxn], rk[maxn][maxn], alive[maxn]; int main(void) { //freopen("h.in", "r", stdin); int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); for (int i=1; i<=n; i++) alive[i] = 1; int v = 0; for (int i=1; i<=n; i++) { scanf("%d", &id[i]); if (id[i]) v = i; } for (int i=1; i<=n; i++) { for (int j=1; j<=n; j++) scanf("%d", &rk[i][j]); } int ko = rk[v][1]; alive[ko] = 0; int num_alive = n - 1; for ( ; id[ko] == 0 && num_alive > 2; ) { for (int i=1; i<=n; i++) if (alive[rk[ko][i]]) { ko = rk[ko][i]; alive[ko] = 0; break; } num_alive--; } if (num_alive == 2 && alive[v]) printf("langren\n"); else printf("lieren\n"); } return 0; }