#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef pair Pii; #define reg register #define mp make_pair #define pb push_back #define Mod1(x) ((x>=P)&&(x-=P)) #define Mod2(x) ((x<0)&&(x+=P)) #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) template inline void cmin(T &a,T b){ ((a>b)&&(a=b)); } template inline void cmax(T &a,T b){ ((a T rd(){ T s=0; int f=0; while(!isdigit(IO=getchar())) f|=IO=='-'; do s=(s<<1)+(s<<3)+(IO^'0'); while(isdigit(IO=getchar())); return f?-s:s; } bool Mbe; const int N=60,INF=1e9+10,P=998244353; int n; int A[N][N]; int vis[N]; int p,q; bool Med; int main(){ rep(_,1,rd()) { n=rd(); rep(i,1,n) if(rd()) p=i; rep(i,1,n) rep(j,1,n) A[i][j]=rd(); q=p; rep(i,1,n) vis[i]=0; while(1) { int c=0; rep(i,1,n) c+=!vis[i]; if(c<=2) { puts("langren"); break; } rep(i,1,n) if(!vis[A[q][i]]) { q=A[q][i]; break; } if(p==q){ puts("lieren"); break; } vis[q]=1; } } }