#include using namespace std; #define rep(i,a,n) for (int i=a;i=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector VI; typedef long long ll; typedef pair PII; typedef double db; mt19937 mrand(random_device{}()); const ll mod=1000000007; int rnd(int x) { return mrand() % x;} ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head const int N = 60; int c[N], r[N][N], vis[N]; int main() { int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); int k = 0; for(int i=1; i<=n; i++) { vis[i] = 1; scanf("%d", &c[i]); if(c[i]) k = i; } for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { scanf("%d", &r[i][j]); } } int cnt = n; bool ans = true; int x = r[k][1]; while(true) { vis[x] = 0; cnt--; if(x==k) { ans = false; break; } if(cnt<=2) { ans = true; break; } int y = 0; for(int i=1; i<=n; i++) { if(vis[r[x][i]]) { y = r[x][i]; break; } } x = y; } if(ans) printf("langren\n"); else printf("lieren\n"); } return 0; }