#include using namespace std; const int maxn=60; int T; int n; int died[maxn]; int kill[maxn][maxn]; int _main(){ cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;++i)died[i]=0; int lang; for(int i=1;i<=n;++i){ int x;scanf("%d",&x); if(x==1)lang=i; } for(int i=1;i<=n;++i){ for(int j=1;j<=n;++j){ scanf("%d",&kill[i][j]); } } if(lang==kill[lang][1]){ printf("lieren\n"); continue; } int last=lang; int nxt; for(int t=1;t<=n-2;++t){ for(int i=1;i<=n;++i){ if(last==kill[last][i])continue; if(died[kill[last][i]])continue; nxt=kill[last][i];break; } died[nxt]=1; last = nxt; if(nxt==lang)break; } if(nxt==lang){ printf("lieren\n"); }else{ printf("langren\n"); } } return 0; } int __ret__=_main(); int main(){}