#include <bits/stdc++.h>
using namespace std;
int n, ar[3100], cur;
vector<int> v;
bool valid, used[10000];
pair<int, string> tab[3100];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tab[i].second >> tab[i].first;
  }
  sort(tab, tab + n);
  valid = true;
  for (int i = 0; i < n; i++) {
    if (tab[i].first > i) valid = false;
  }
  if (valid) {
    cur = tab[0].first;
    for (int i = 0; i < n; i++) {
      ar[i] = 10;
      if (tab[i].first > cur) {
        for (int j = 0; j < v.size(); j++) {
          ar[v[j]]++;
        }
        int bil = tab[i].first - cur;
        int j = i;
        while (bil > 0) {
          j--;
          if (used[j]) continue;
          used[j] = true;
          v.push_back(j);
          bil--;
        }
        cur = tab[i].first;
      }
    }
    for (int j = 0; j < v.size(); j++) {
      ar[v[j]]++;
    }
    for (int i = 0; i < n; i++) {
      cout << tab[i].second << " " << ar[i] << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
