#include <bits/stdc++.h>
using namespace std;
struct person {
  string name;
  int more;
  int mark;
  int len;
};
void qsort(int l, int r, person* ar) {
  int i = l, j = r;
  person s = ar[(l + r) / 2];
  while (i < j) {
    while (s.more > ar[i].more) i++;
    while (s.more < ar[j].more) j--;
    if (i <= j) {
      person k = ar[i];
      ar[i] = ar[j];
      ar[j] = k;
      i++;
      j--;
    }
  }
  if (i < r) qsort(i, r, ar);
  if (l < j) qsort(l, j, ar);
}
void qsort2(int l, int r, person* ar) {
  int i = l, j = r;
  person s = ar[(l + r) / 2];
  while (i < j) {
    while (s.mark > ar[i].mark) i++;
    while (s.mark < ar[j].mark) j--;
    if (i <= j) {
      person k = ar[i];
      ar[i] = ar[j];
      ar[j] = k;
      i++;
      j--;
    }
  }
  if (i < r) qsort2(i, r, ar);
  if (l < j) qsort2(l, j, ar);
}
int main() {
  int n;
  cin >> n;
  person* ar = new person[n];
  int* mark = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i].name >> ar[i].more;
    ar[i].mark = 0;
    ar[i].len = 0;
  }
  qsort(0, n - 1, ar);
  int count = 0;
  int more = 0;
  int len = n;
  while (count != n) {
    int i = 0;
    for (i = 0; i < n; i++)
      if (ar[i].mark == 0 && ar[i].more == more) break;
    if (i == n) {
      int j = 0;
      for (j = n; j >= 0; j--)
        if (ar[j].mark == 0 && ar[j].more < more) break;
      if (j == -1) {
        cout << -1;
        return 0;
      }
      count++;
      ar[j].mark = count;
      int k = j;
      for (j = 0; j < n; j++)
        if (ar[j].mark != 0 && ar[j].more == ar[k].more) break;
      ar[k].len = ar[j].len;
      more++;
    } else {
      count++;
      ar[i].mark = count;
      ar[i].len = len;
      len--;
      more++;
    }
  }
  qsort2(0, n - 1, ar);
  for (int i = 0; i < n; i++) cout << ar[i].name << " " << ar[i].len << endl;
  cin >> n;
  return 0;
}
