#include <bits/stdc++.h>
using namespace std;
struct man {
  string name;
  int k, l;
};
bool by_k(man x, man y) { return (x.k < y.k); }
vector<man> a;
vector<man> now, temp;
int n;
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i].name >> a[i].k;
  sort(a.begin(), a.end(), by_k);
  int s = 0;
  for (int i = 0; i < a.size(); i++) {
    temp.clear();
    if (now.size() < a[i].k) goto fail;
    for (int j = 0; j < a[i].k; j++) {
      temp.push_back(now[j]);
    }
    a[i].l = n - s;
    temp.push_back(a[i]);
    while (i + 1 < a.size() && a[i + 1].k == a[i].k) {
      i++;
      a[i].l = n - s;
      temp.push_back(a[i]);
    }
    for (int j = a[i].k; j < now.size(); j++) temp.push_back(now[j]);
    now.swap(temp);
    s++;
  }
  for (int i = 0; i < n; i++) cout << now[i].name << ' ' << now[i].l << endl;
  return 0;
fail:
  cout << "-1";
  return 0;
}
