import java.util.*; // import java.io.*; //comment out when submitting public class m { Scanner in = new Scanner(System.in); // static Scanner in = null; public static void main(String[] args) { // comment out this part // try { // File file = new File("input.txt"); // in = new Scanner(file); // } catch(FileNotFoundException e) { // System.out.println("error"); // } new m().go(); } private void go() { //read the input int n = Integer.parseInt(in.nextLine()); while(in.hasNextLine()) { String[] inputs = in.nextLine().split(" "); String name = inputs[0]; int postSecondaryYear = Integer.parseInt(inputs[1].split("/")[0]); int birthYear = Integer.parseInt(inputs[2].split("/")[0]); int courseNum = Integer.parseInt(inputs[3]); if(postSecondaryYear >= 2010 || birthYear >= 1991) { System.out.println(name + " eligible"); } else if(courseNum > 40) { System.out.println(name + " ineligible"); } else { System.out.println(name + " coach petitions"); } } } }