/** * author: roccoshi * created: 2021-07-31 14:09:59 */ #include using namespace std; #define ll long long #define endl '\n' #define pii pair #define mp make_pair #define pb push_back #define fi first #define se second const int pi = 3.1415927; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int ninf = 0xc0c0c0c0; const int N = 55; int id[N]; int die[N][N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int idx = -1; set lives; // 活着的人 for (int i = 1; i <= n; ++i) { lives.insert(i); cin >> id[i]; if (id[i] == 1) idx = i; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cin >> die[i][j]; } } int now = die[idx][1]; lives.erase(now); while (lives.size() > 2 && lives.count(idx)) { for (int i = 1; i <= n; ++i) { if (lives.count(die[now][i])) { now = die[now][i]; lives.erase(now); break; } } } if (!lives.count(idx)) cout << "lieren" << endl; else cout << "langren" << endl; } return 0; }