#include using namespace std; bool alive[55]={1}; int shenfen[55]; int rank_list[55][55]; bool check(int n,int num){ int count=1; int alive_num=n; int temp; while(count){ if(count==1){ alive[rank_list[num][1]]=0; temp=rank_list[num][1]; alive_num--; } else{ if(temp==num)return 0; if(alive_num<=2)return 1; for(int i=1;i<=n;i++){ if(i==temp){ for(int j=1;j<=n;j++){ if(alive[rank_list[temp][j]]==1&&rank_list[temp][j]!=i){ alive[rank_list[temp][j]]=0; temp=rank_list[temp][j]; alive_num--; break; } } break; } } } count++; } } int main(){ ios::sync_with_stdio(false); int T,n; cin>>T; while(T--){ cin>>n; int num;//狼人编号 memset(alive,1,sizeof(alive)); for(int i=1;i<=n;i++){ cin>>shenfen[i]; if(shenfen[i]==1) num=i; } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>rank_list[i][j]; } } if(check(n,num))cout<<"langren"<