Problem: In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.

After a while the cashier has a lunch break and the people in the queue seat on the chairs in the waiting room in a random order.

When the lunch break was over, it turned out that nobody can remember the exact order of the people in the queue, but everyone remembers his number ai.

Your task is to restore the order in which the people stood in the queue if it is possible. There may be several acceptable orders, but you need to find any of them. Also, you need to print a possible set of numbers hi — the heights of people in the queue, so that the numbers ai are correct.

Input

The first input line contains integer n — the number of people in the queue (1 ≤ n ≤ 3000). Then n lines contain descriptions of the people as "namei ai" (one description on one line), where namei is a non-empty string consisting of lowercase Latin letters whose length does not exceed 10 characters (the i-th person's name), ai is an integer (0 ≤ ai ≤ n - 1), that represents the number of people who are higher and stand in the queue in front of person i. It is guaranteed that all names are different.

Output

If there's no acceptable order of the people in the queue, print the single line containing "-1" without the quotes. Otherwise, print in n lines the people as "namei hi", where hi is the integer from 1 to 109 (inclusive), the possible height of a man whose name is namei. Print the people in the order in which they stand in the queue, starting from the head of the queue and moving to its tail. Numbers hi are not necessarily unique.

Examples

Input

4
a 0
b 2
c 0
d 0


Output

a 150
c 170
d 180
b 160


Input

4
vasya 0
petya 1
manya 3
dunay 3


Output

-1

Solution (in JAVA):

Solution:
//                I know stuff but probably my rating tells otherwise...

//                  Love is no stone, it's soft... more like snow
//                        beautifying everything it covers
//                        And when it falls... you listen

//               Kya hua, code samajhne ki koshish kar rhe ho?? Mat karo,
//                      mujhe bhi samajh nhi aata kya likha hai


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class _141C {

      static void Mangni_ke_bail_ke_dant_na_dekhal_jye() {
            n = ni();
            data[] inp = new data[n];
            for (int i = 0; i < n; i++) inp[i] = new data(ns(), ni());
            Arrays.sort(inp, (data a, data b) -> a.b - b.b);
            int ans[] = new int[n];

            for (int i = 0; i < n; i++) {
                  if (inp[i].b > i) {
                        pl(-1);
                        return;
                  }
            }

            for (int i = 0; i < n; i++) {

                  int dif = i - inp[i].b;
                  ans[i] = dif;
                  for (int j = 0; j < i; j++) {
                        if(ans[i] <= ans[j])ans[j]++;
                  }
                  //pl(Arrays.toString(ans));
            }

            for(int i=0;i<n;i++)pl(inp[i].a+" "+(ans[i] + 1));
      }

      static class data{
            String a; int b;
            data(String a, int b){
                  this.a = a;
                  this.b= b;
            }
      }


      //----------------------------------------The main code ends here------------------------------------------------------
      /*-------------------------------------------------------------------------------------------------------------------*/
      //-----------------------------------------Rest's all dust-------------------------------------------------------------


      static int mod9 = 1_000_000_007;
      static int n, m, l, k, t;
      static AwesomeInput input;
      static PrintWriter pw;

      static long power(long a, long b) {
            long x = max(a, b);
            if (b == 0) return 1;
            if ((b & 1) == 1) return a * power(a * a, b >> 1);
            return power(a * a, b >> 1);
      }

      static long modpow(long a, long b, long m) {
            if (b == 0) return 1;

            if ((b & 1) == 1) return a * modpow(a * a % m, b >> 1, m) % m;
            return modpow(a * a % m, b >> 1, m) % m;
      }

      // The Awesome Input Code is a fast IO method //
      static class AwesomeInput {
            private InputStream letsDoIT;
            private byte[] buf = new byte[1024];
            private int curChar;
            private int numChars;
            private SpaceCharFilter filter;

            private AwesomeInput(InputStream incoming) {
                  this.letsDoIT = incoming;
            }

            public int read() {
                  if (numChars == -1)
                        throw new InputMismatchException();
                  if (curChar >= numChars) {
                        curChar = 0;
                        try {
                              numChars = letsDoIT.read(buf);
                        } catch (IOException e) {
                              throw new InputMismatchException();
                        }
                        if (numChars <= 0)
                              return -1;
                  }
                  return buf[curChar++];
            }

            private long ForLong() {
                  int c = read();
                  while (isSpaceChar(c))
                        c = read();
                  int sgn = 1;
                  if (c == '-') {
                        sgn = -1;
                        c = read();
                  }
                  long res = 0;
                  do {
                        if (c < '0' || c > '9')
                              throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = read();
                  }
                  while (!isSpaceChar(c));
                  return res * sgn;
            }

            private String ForString() {
                  int c = read();
                  while (isSpaceChar(c))
                        c = read();
                  StringBuilder res = new StringBuilder();
                  do {
                        res.appendCodePoint(c);
                        c = read();
                  }
                  while (!isSpaceChar(c));

                  return res.toString();
            }

            public boolean isSpaceChar(int c) {
                  if (filter != null)
                        return filter.isSpaceChar(c);
                  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }

            public interface SpaceCharFilter {
                  boolean isSpaceChar(int ch);
            }
      }

      // functions to take input//
      static int ni() {
            return (int) input.ForLong();
      }

      static String ns() {
            return input.ForString();
      }

      static long nl() {
            return input.ForLong();
      }

      //functions to give output
      static void pl() {
            pw.println();
      }

      static void p(Object o) {
            pw.print(o + " ");
      }

      static void pws(Object o) {
            pw.print(o + "");
      }

      static void pl(Object o) {
            pw.println(o);
      }

      // Fast Sort is Radix Sort
      public static int[] fastSort(int[] f) {
            int n = f.length;
            int[] to = new int[n];
            {
                  int[] b = new int[65537];
                  for (int i = 0; i < n; i++) b[1 + (f[i] & 0xffff)]++;
                  for (int i = 1; i <= 65536; i++) b[i] += b[i - 1];
                  for (int i = 0; i < n; i++) to[b[f[i] & 0xffff]++] = f[i];
                  int[] d = f;
                  f = to;
                  to = d;
            }
            {
                  int[] b = new int[65537];
                  for (int i = 0; i < n; i++) b[1 + (f[i] >>> 16)]++;
                  for (int i = 1; i <= 65536; i++) b[i] += b[i - 1];
                  for (int i = 0; i < n; i++) to[b[f[i] >>> 16]++] = f[i];
                  int[] d = f;
                  f = to;
                  to = d;
            }
            return f;
      }

      public static void main(String[] args) {      //threading has been used to increase the stack size.
            try {
                  input = new AwesomeInput(System.in);
                  pw = new PrintWriter(System.out, true);
                  input = new AwesomeInput(new FileInputStream("/home/saurabh/Desktop/input.txt"));
                  pw = new PrintWriter(new BufferedWriter(new FileWriter("/home/saurabh/Desktop/output.txt")), true);

            } catch (Exception e) {
            }

            new Thread(null, null, "AApan_gand_hawai_dusar_ke_kare_dawai", 1 << 25)  //the last parameter is stack size desired.
            {
                  public void run() {
                        try {
                              double s = System.currentTimeMillis();
                              Mangni_ke_bail_ke_dant_na_dekhal_jye();
                              //System.out.println(("\nExecution Time : " + ((double) System.currentTimeMillis() - s) / 1000) + " s");
                              pw.flush();
                              pw.close();
                        } catch (Exception e) {
                              e.printStackTrace();
                              System.exit(1);
                        }
                  }
            }.start();
      }
}