#include using namespace std; const int maxn = 50; int T, n; int a[maxn + 10], b[maxn + 10][maxn + 10], d[maxn + 10]; int id; int main() { scanf("%d", &T); while (T--) { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); if (a[i] == 1) id = i; } for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) scanf("%d", &b[i][j]); for (int i = 1; i <= n; ++i) d[i] = 0; int p = b[id][1]; d[p] = 1; int cnt = n - 1; while (cnt > 2) { int x = 0; for (int i = 1; i <= n; ++i) if (!d[b[p][i]]) { x = b[p][i]; break; } d[x] = 1; --cnt; p = x; if (x == id || cnt <= 2) break; } if (d[id]) printf("lieren\n"); else printf("langren\n"); } }