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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Saransh
 */
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;


public class Main {

    static class Person implements Comparable<Person>
    {
        String name;
        int greaters;
        
        public Person(String n,int g)
        {
            name=n;
            greaters=g;
        
        }
        public int compareTo(Person o)
        {
            return greaters-o.greaters;
        }
    }
    static class Node implements Comparable<Node>
    {
        int pos,height;
        public Node(int p,int h)
        {
            pos=p;
            height=h;
        }
        public int compareTo(Node o)
        {
            return -height+o.height;
        }
    }
    static int array[];
    public static void main(String[] args) {
        // TODO code application logic here
        try
        {
            Parserdoubt pd=new Parserdoubt(System.in);
            int x=1;
            if(x==1)
            {
                int n=pd.nextInt();
                Person p[]=new Person[n];
                for(int i=0;i<n;i++)
                    p[i]=new Person(pd.nextString(),pd.nextInt());
                Arrays.sort(p);
                boolean possible=true;
                PriorityQueue<Node> q=new PriorityQueue<Node>();
                Queue<Node> nq=new LinkedList<Node>();
                int print[]=new int[n];
                for(int i=0;i<p.length;i++)
                {
                    int m=p[i].greaters;
                    if(q.size()<m)
                    {
                        possible = false;
                        break;
                    }
                    nq.clear();
                    int use=i+1;
                    for(int j=0;j<m;j++)
                    {
                        Node tmp=q.poll();
                        use=tmp.height;
                        print[tmp.pos]++;
                        tmp.height++;
                        nq.add(tmp);
                    }
                    print[i]=use;
                    while(nq.size()>0)
                        q.add(nq.poll());
                    q.add(new Node(i,use));
                }
                if(possible)
                {
                    for(int i=0;i<n;i++)
                        System.out.println(p[i].name+" "+print[i]);
                }
                else
                    System.out.println(-1);
                return;
            }
            int n=pd.nextInt();
            int m=pd.nextInt();
            int arr[][]=new int[m][2];
            char clearer[]=new char[m];
            array = new int[n];
            Arrays.fill(array, -1);
            int santa=0,elf=0;
            for(int i=0;i<m;i++)
            {
                arr[i][0]=pd.nextInt()-1;
                arr[i][1]=pd.nextInt()-1;
                clearer[i]=pd.nextChar();
                if(clearer[i]=='S')
                    santa++;
                else
                    elf++;
            }
            int santa_arr[][]=new int[santa][3];
            int elf_arr[][]=new int[elf][3];
            santa=0;
            elf=0;
            for(int i=0;i<arr.length;i++)
            {
                if(clearer[i]=='S')
                {
                    santa_arr[santa][0]=arr[i][0];
                    santa_arr[santa][1]=arr[i][1];
                    santa_arr[santa][2]=i;
                    santa++;
                }
                else
                {
                    elf_arr[elf][0]=arr[i][0];
                    elf_arr[elf][1]=arr[i][1];
                    elf_arr[elf][2]=i;
                    elf++;
                }
            }
            boolean marked[]=new boolean[m];
            boolean ok=true;
            boolean usesanta=true;
            int possanta=0,poself=0;
            int donesanta=0,doneelf=0;
            while(ok)
            {
                ok=false;
                if(usesanta)
                {
                    for(int i=possanta;i<santa;i++)
                    {
                        int v1 = find(santa_arr[i][0]);
                        int v2 = find(santa_arr[i][1]);
                        if(v1!=v2)
                        {
                            union(v1,v2);
                            donesanta++;
                            possanta=i+1;
                            marked[santa_arr[i][2]]=true;
                            usesanta=!usesanta;
                            ok=true;
                            break;
                        }
                    }

                }
                else
                {

                    for(int i=poself;i<elf;i++)
                    {
                        int v1 = find(elf_arr[i][0]);
                        int v2 = find(elf_arr[i][1]);
                        if(v1!=v2)
                        {
                            union(v1,v2);
                            doneelf++;
                            poself=i+1;
                            marked[elf_arr[i][2]]=true;
                            usesanta=!usesanta;
                            ok=true;
                            break;
                        }
                    }
                }
            }
            if(donesanta==doneelf&&((donesanta+doneelf)==n-1))
            {
                System.out.println(n-1);
                for(int i=0;i<marked.length;i++)
                {
                    if(marked[i])
                        System.out.print((i+1)+" ");
                }
            }
            else
            {
                System.out.println(-1);
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

    }
    public static void union(int root1, int root2) {
        if (array[root2] < array[root1]) {
            array[root1] = root2;             // root2 is taller; make root2 new root
        } else {
            if (array[root1] == array[root2]) {
                array[root1]--;            // Both trees same height; new one is taller
            }
            array[root2] = root1;       // root1 equal or taller; make root1 new root
        }
    }

    public static int find(int x) {
        if (array[x] < 0) {
            return x;                         // x is the root of the tree; return it
        } else {
            // Find out who the root is; compress path by making the root x's parent.
            array[x] = find(array[x]);
            return array[x];                                       // Return the root
        }
    }
}


class Parserdoubt
    {
       final private int BUFFER_SIZE = 1 << 17;

       private DataInputStream din;
       private byte[] buffer;
       private int bufferPointer, bytesRead;

       public Parserdoubt(InputStream in)
       {
          din = new DataInputStream(in);
          buffer = new byte[BUFFER_SIZE];
          bufferPointer = bytesRead = 0;
       }
       public String nextString() throws Exception
       {
           StringBuffer sb=new StringBuffer("");
           byte c = read();
           while (c <= ' ') c = read();
           do
           {
               sb.append((char)c);
               c=read();
           }while(c>' ');
           return sb.toString();
       }
       public char nextChar() throws Exception
       {
           byte c=read();
           while(c<=' ') c= read();
           return (char)c;
       }
       public int nextInt() throws Exception
       {
          int ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       public long nextLong() throws Exception
       {
          long ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       private void fillBuffer() throws Exception
       {
          bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
          if (bytesRead == -1) buffer[0] = -1;
       }

       private byte read() throws Exception
       {
          if (bufferPointer == bytesRead) fillBuffer();
          return buffer[bufferPointer++];
       }
    }