// Arup Guha
// 1/22/2017
// Solution to 2017 January USACO Bronze problem: Don't Be Last!

import java.util.*;
import java.io.*;

public class notlast {

	// These will be useful.
	final public static String[] COWS = {"Bessie", "Elsie", "Daisy", "Gertie", "Annabelle", "Maggie", "Henrietta"};
	public static HashMap<String,Integer> map;

	public static void main(String[] args) throws Exception {

		// Just set up the map based on the list.
		map = new HashMap<String,Integer>();
		for (int i=0; i<COWS.length; i++)
			map.put(COWS[i], i);

		// Set up our pairs.
		Scanner stdin = new Scanner(new File("notlast.in"));
		int n = stdin.nextInt();
		pair[] list = new pair[COWS.length];
		for (int i=0; i<COWS.length; i++)
			list[i] = new pair(COWS[i], 0);

		// Process each milking session.
		for (int i=0; i<n; i++) {
			String name = stdin.next();
			int myV = stdin.nextInt();
			list[map.get(name)].votes += myV;
		}

		// Sort by milk production.
		Arrays.sort(list);

		// Go to first non-minimim value.
		int i = 0;
		while (i < list.length && list[i].votes == list[0].votes) i++;

		// Now output the result, watch out for array out of bounds!
		PrintWriter out = new PrintWriter(new FileWriter("notlast.out"));
		if (i == list.length || (i < list.length-1 && list[i].votes == list[i+1].votes))
			out.println("Tie");
		else
			out.println(list[i].name);

		out.close();
		stdin.close();
	}
}

class pair implements Comparable<pair> {

	public String name;
	public int votes;

	public pair(String n, int v) {
		name = n;
		votes = v;
	}

	public int compareTo(pair other) {
		return this.votes - other.votes;
	}
}