#include <bits/stdc++.h>
using namespace std;
const int N = 30000;
struct person {
  char name[20];
  int a, h;
};
struct person Q[N + 100];
int n;
int pos, head, h[N + 100];
bool cmp(person A, person B) { return (A.a < B.a); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s %d", &Q[i].name, &Q[i].a);
  sort(Q + 1, Q + n + 1, cmp);
  int f = 1, p = 1;
  bool flag = true;
  while (f <= n) {
    while (p + 1 <= n && Q[p].a == Q[p + 1].a) p++;
    if (f - 1 < Q[f].a) {
      flag = false;
      break;
    }
    int m = Q[f].a;
    pos = head;
    for (int i = 1; i <= m - 1; i++) {
      pos = h[pos];
    }
    for (int i = p; i >= f; i--) {
      h[i] = i - 1;
    }
    h[f] = h[pos];
    if (head == 0)
      head = p;
    else
      h[pos] = p;
    f = p + 1;
    p = p + 1;
  }
  if (flag) {
    pos = head;
    for (int i = 1; i <= n; i++) {
      Q[pos].h = n - i + 1;
      pos = h[pos];
    }
    for (int i = 1; i <= n; i++) printf("%s %d\n", Q[i].name, Q[i].h);
  } else
    printf("-1\n");
  return 0;
}
