#include using namespace std; int main() { int t; cin >> t; while(t--){ int n; cin >> n; int f[55] = {0}; int d[55] = {0}; int langren = 0; for(int i = 1;i <= n;i++){ cin >> f[i]; if(f[i]){ langren = i; } } int m[55][55] = {0}; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ cin >> m[i][j]; } } int now = langren; int len = n; while(len > 2){ for(int i = 1;i <= n;i++){ if(d[m[now][i]] == 0){ d[m[now][i]] = 1; now = m[now][i]; len--; break; } } if(d[langren]){ break; } } if(d[langren]){ cout << "lieren" << endl; }else{ cout << "langren" << endl; } } return 0; }