Problem:
Score : 200 points

Problem Statement

You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

1 ≤ N ≤ 100

S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

0 ≤ P_i ≤ 100

P_i is an integer.

P_i ≠ P_j (1 ≤ i < j ≤ N)

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;



/** テンプレート */
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();

		PairSI[] pair = new PairSI[N];
		for(int i =0 ; i < N; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			pair[i] = new PairSI(s, p, i+1);
		}

//		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
		Arrays.sort(pair, new Comparator<PairSI>() {
			public int compare(PairSI o1, PairSI o2) {
				if(o1.k.compareTo(o2.k) == 0) {
					return Integer.compare(o2.v, o1.v); //Java7以降
				}else {
					return o1.k.compareTo(o2.k);
				}
			}
		});

		//************************************/
		// ここから出力処理
		//************************************/
		PrintWriter out = new PrintWriter(System.out);

		for(int i = 0; i < N; i++) {
			out.println(pair[i].num);
		}

		// 最後に必ずFlush
		out.flush();
	}
}

///** テンプレート */
//public class Main {
//	final static int SSSSS = 1000000;
//
//
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int K = sc.nextInt();
//
//		double ans = 0;
//		int min = Main.calc(K);
//		int count = 1;
//
//
//		if(K <= N) {
//
//			for(int i=2; i<=K-1; i++) {
//
//				 count += min / Main.calc((int)Math.ceil((double)K / i));
//
//			}
////			//deb
////			out.println(count);
//
//			ans = (double)(count+(N-K+1)*min)/(N * min);
//
//		}else {
//			for(int i=2; i<=N; i++) {
////				//deb
////				out.println("count:");
////				out.println(count);
////				out.println("ceil:");
////				out.println(((int)Math.ceil(K / i)));
////				out.println("calc:");
////				out.println(Main.calc((int)Math.ceil(K / i)));
////				out.println("min / calc:");
////				out.println(min / Main.calc((int)Math.ceil(K / i)));
////				out.flush();
////				//
//
//
//				 count += min / Main.calc((int)Math.ceil((double)K / i));
//			}
//
//			ans = (double)count/(N * min);
//		}
//
//
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//
//		out.println(ans);
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//
//
//	/**
//	 * xが2のべき乗かどうか調べる関数
//	 * @param x
//	 * @return 2のべき乗ならtrue。0はfalse。
//	 */
//	static boolean isPowerOfTwo(int x){
//	    return x > 0 && (x & (x - 1)) == 0;
//	}
//
//	static int calc(int num) {
//	    if(isPowerOfTwo(num)){
//	    	return num;
//	    }
//
//		int ret = 0;
//		for(int shift=2; shift<31; shift++){ // 32bit符号付整数なので30回シフト=2^31が限界
//			ret = 1 << shift;                // 1を左シフトして2のべき乗を生成
//			if(ret > num){
//				return  ret;
//			}
//		}
//		return ret;
//	}
//
//
//}



//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		String s = sc.next();
//
//		int sint = new Integer(s).intValue();
//		int up = sint / 100;
//		int down = sint % 100;
//
//		boolean UPMM = false;
//		if(1 <= up && up <=12) {
//			UPMM = true;
//		}
//
//		boolean DWMM = false;
//		if(1 <= down && down <=12) {
//			DWMM = true;
//		}
//
//
//
//
//
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//		if(UPMM && DWMM) {
//			out.println("AMBIGUOUS");
//		}else if(UPMM && !DWMM) {
//			out.println("MMYY");
//		}else if(!UPMM && DWMM) {
//			out.println("YYMM");
//		}else {
//			out.println("NA");
//		}
//
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}



//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int K = sc.nextInt();
//		String S = sc.next();
//
//		PrintWriter out = new PrintWriter(System.out);
//
//		for (int i = 0; i < N; i++) {
//			char c = S.charAt(i);
//			if(i != K-1) {
//				out.print(c);
//			}else {
//				out.print(Character.toLowerCase(c));
//			}
//		}
//
//
//
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//	//	PrintWriter out = new PrintWriter(System.out);
//
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}



///** テンプレート */
//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int M = sc.nextInt();
//
//		int[] ary = new int[N];
//		for (int i = 0; i < N; i++) {
//			ary[i] = sc.nextInt();
//		}
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//
//		out.println("hoge");
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}




/** スキャン用 */
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	/** クラス内部用だよ */
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	/** クラス内部用だよ */
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	/**
	 * クラス内部用だよ
	 * ASCII の文字の内、表示用の文字を返す関数
	 *
	 * @return 改行とか制御文字じゃない、表示用文字ならtrue
	 * */
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	/**
	 * @return 改行文字とか空白以外を除いた、次の文字があればtrue
	 * */
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	/**
	 *
	 * @return 次の文字列
	 */
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}

		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	/**
	 *
	 * @return 次のLong
	 */
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	/**
	 *
	 * @return 次のInt
	 */
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	/**
	 *
	 * @return 次のDouble
	 */
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

class Pair {
	int k;
	int v;

	public Pair(int k, int v) {
		this.k = k;
		this.v = v;
	}
}

class PairSI {
	String k;
	int v;
	int num; // 出現順

	public PairSI(String k, int v, int num) {
		this.k = k;
		this.v = v;
		this.num = num;
	}
}

//class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
//	/** serialVersionUID. */
//	private static final long serialVersionUID = 6411527075103472113L;
//
//	public Pair(final K key, final V value) {
//		super(key, value);
//	}
//}