#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int n, r[3500];
pair<int, string> a[3500];
set<pair<int, int> > s;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i].second >> a[i].first;
  sort(a, a + n);
  for (int i = 0; i < n; ++i)
    if (a[i].first > i) {
      cout << "-1";
      return 0;
    }
  int l = 100000, w;
  set<pair<int, int> > s1;
  pair<int, int> q;
  for (int i = 0; i < n; ++i) {
    if (!i || a[i].first == 0) {
      r[i] = l++;
      s.insert(make_pair(-r[i], i));
      continue;
    }
    s1.clear();
    w = 1;
    for (set<pair<int, int> >::iterator it = s.begin();
         (a[i].first-- > 0) && it != s.end(); it++) {
      q = *it;
      s.erase(q);
      w = q.first;
      q.first--;
      s.insert(q);
      r[q.second] = -q.first;
    }
    s.insert(make_pair(w, i));
    r[i] = -w;
    l++;
  }
  for (set<pair<int, int> >::iterator it = s.begin(); it != s.end(); it++) {
    pair<int, int> q = *it;
    r[q.second] = -q.first;
  }
  for (int i = 0; i < n; ++i) cout << a[i].second << " " << r[i] << endl;
  return 0;
}
