import java.awt.List;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;

public class denisov_dg {

	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;

	String next() throws IOException {
		String help;
		while ((str == null) || (!str.hasMoreTokens())) {
			help = in.readLine();
			if (help == null) {
				return null;
			}
			str = new StringTokenizer(help);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	
	
	
	public void solve() throws IOException {
		in = new BufferedReader(new FileReader("denisov.in"));
		int n = nextInt();
		int maxSallary = Integer.MIN_VALUE;
		String name = null;
		int curSallary;
		String curName;
		for (int i = 0; i < n; i++) {
			curSallary = nextInt();
			curName = next();
			if (next().equals("Russia") && curSallary > maxSallary) {
				maxSallary = curSallary;
				name = curName;
			}
		}
		out = new PrintWriter("denisov.out");
		out.println(name);
		out.close();
	}

	static void myAssert(boolean b, String string) {
		if (!b) {
			throw new AssertionError(string);
		}
	}

	public static void main(String[] args) throws IOException {
		new denisov_dg().solve();
	}
}
