// Arup Guha
// 4/11/2017, edited on 7/28/2026 to avoid doubles.
// Solution to 1992 UCF HS Contest Problem: The Impulsive Traveling Salesman

import java.util.*;

public class salesman {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Process each case
		while (stdin.hasNext()) {

			// Read in city information.
			int n = Integer.parseInt(stdin.nextLine().trim());
			city[] list = new city[n];
			for (int i=0; i<n; i++) {
				String s = stdin.nextLine();
				StringTokenizer tok = new StringTokenizer(stdin.nextLine());
				int x = Integer.parseInt(tok.nextToken());
				int y = Integer.parseInt(tok.nextToken());
				list[i] = new city(s,x,y);
			}

			// Always start at the first city in our list.
			boolean[] used = new boolean[n];
			int cur = 0;
			used[0] = true;

			// Keep on going.
			for (int i=0; i<n-1; i++) {

				// This is more than 2*65536*65536
				long close = 10000000000L;
				int next = -1;

				// Try each item as next, to see which is closest.
				for (int j=0; j<n; j++) {
					if (!used[j] && list[cur].distsq(list[j]) < close) {
						close = list[cur].distsq(list[j]);
						next = j;
					}
				}
				
				/*** Added to check for equality at each step.
					Not needed for the solution. ***/
				for (int j=0; j<n; j++) {
					if (used[j]) continue;
					if (j == next) continue;
					
					if (list[cur].distsq(list[j]) == list[cur].distsq(list[next]))
						System.out.println("ERROR TIE FOR BEST");
				}
				/*** End of check ***/

				// Update where we are.
				cur = next;
				used[cur] = true;
			}

			// Output last location.
			System.out.println("Salesman ends up in "+list[cur].name+".");
		}
	}
}

class city {

	public String name;
	public int x;
	public int y;

	public city(String s, int myx, int myy) {
		name = s;
		x = myx;
		y = myy;
	}
	
	public long distsq(city other) {
		long dx = x - other.x;
		long dy = y - other.y;
		return dx*dx + dy*dy;
	}
}