#include #include #include #include #include #include #include #include #include #define X first #define Y second #define PB push_back #define MP make_pair #define EB emplace_back #define mset(var,val) memset(var,val,sizeof(var)) #define IOS ios::sync_with_stdio(false);cin.tie(0) #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; typedef long long ll; #ifdef local #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0) void err() { cout << endl; } template class T, typename t, typename... Args> void err(T a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); } template void err(T a, Args... args) { cout << a << ' '; err(args...); } #else #define dbg(...) #endif typedef pair pii; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos(-1.0); const double eps = 1e-8; const int mod=998244353; const int N = 50+5; const int M = N*100; const int maxn=1e7+50; int lan; queueq[N]; int a[N]; void work() { int n; cin >> n; lan = 0; for (int i = 1; i <= n; ++i) { a[i] = 1; int x; cin >> x; if (x) { lan = i; } } for (int i = 1; i <= n; ++i) { while(!q[i].empty()) q[i].pop(); for (int j = 1; j <= n; ++j) { int x; cin >> x; q[i].emplace(x); } } // dbg(lan); int save = n; int u = lan; while(true) { while(!q[u].empty()) { int x = q[u].front(); q[u].pop(); if (x == u and u != lan) continue; if (a[x]) { u = x; break; } } a[u] = 0; --save; if (u == lan or (u != lan and save <= 2) ) break; // while(!q[kill].empty()) { // int x = q[kill].front(); // q[kill].pop(); // if (x == kill) continue; // if (a[x]) { // kill = x; // break; // } // } // a[kill] = 0; // --save; //// dbg(kill); // if (kill == lan or (kill != lan and save <= 2) ) break; } if (a[lan]) { cout << "langren\n"; } else { cout << "lieren\n"; } } int main() { #ifdef local freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); #endif // local IOS; // init(); int t; cin>>t; while(t--) work(); return 0; }