import java.util.Scanner; public class Main { public static void main(String[] args) { int[] ids = new int[55]; int[][] toKills = new int[55][55]; Scanner scanner = new Scanner(System.in); int T = scanner.nextInt(); while (scanner.hasNext()){ int n = scanner.nextInt(); for (int i = 0; i < n; i++) { ids[i]=scanner.nextInt(); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { toKills[i][j] = scanner.nextInt(); } } System.out.println(getResult(ids,toKills,n)); T--; } scanner.close(); } public static String getResult(int[] ids,int[][] toKills,int n){ int lrId = -1; int[] death = new int[n+1]; for (int i = 0; i < n; i++) { if(ids[i]==1){ lrId=i+1; } } int live = n-1; int curDeathId = toKills[lrId-1][0]; if(curDeathId==lrId){ return "lieren"; } death[curDeathId]=1; while (live>2){ int nextDeathId = 0; for (int i = 0; i < n; i++) { nextDeathId = toKills[curDeathId-1][i]; if(death[nextDeathId]==0){ death[nextDeathId] = 1; break; } } if(nextDeathId==lrId){ return "lieren"; } curDeathId = nextDeathId; live--; } return "langren"; } }