// Arup Guha
// 1/28/2017
// Example to show the basic use of an TreeSet in Java.

import java.util.*;

public class usets {

	public static void main(String[] args) {

		// Read in the number of steps.
		Scanner stdin = new Scanner(System.in);
		int numSteps = stdin.nextInt();
		TreeSet<employee> myset = new TreeSet<employee>();

		// Process each step.
		for (int i=0; i<numSteps; i++) {

			int op = stdin.nextInt();

			// 1 is adding an employee.
			if (op == 1) {
				String name = stdin.next();
				int salary = stdin.nextInt();
				int exp = stdin.nextInt();
				myset.add(new employee(name, salary, exp));
				System.out.println("added "+name);
			}

			// This finds the employee who makes the least money but makes at least minSal.
			else {

				int minSal = stdin.nextInt();
				employee dummy = new employee("johndoe", minSal, -1);
				
				// Nifty method in the TreeSet class.
				employee picked = myset.higher(dummy);

				// Oops, nothing is higher in the tree.
				if (picked == null)
					System.out.println("Sorry, no one can do this job.");
				
				// We have someone for the job!
				else {
					System.out.println("We have chosen "+picked.name+" for the job.");
					myset.remove(picked);
				}
			}
		}
	}
}

class employee implements Comparable<employee> {

	public String name;
	public int salary;
	public int experience;

	public employee(String n, int myS, int myE) {
		name = n;
		salary = myS;
		experience = myE;
	}

	// Just based on salary, ties broken by experience.
	public int compareTo(employee other) {
		if (this.salary != other.salary)
			return this.salary - other.salary;
		return this.experience - other.experience;
	}
}