#include <bits/stdc++.h>
typedef struct {
  char n[11];
  int a;
  int h;
} P;
P *A[3000];
int n;
int *H[3000];
int comp(const void *p, const void *q) {
  return (*((P **)p))->a - (*((P **)q))->a;
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    A[i] = (P *)malloc(sizeof(P));
    scanf("%s %d", A[i]->n, &(A[i]->a));
  }
  qsort(A, n, sizeof(P *), comp);
  for (i = 0; i < n; i++) {
    if (A[i]->a > i) {
      printf("-1");
      return 0;
    }
  }
  A[0]->h = 1;
  H[0] = &(A[0]->h);
  for (i = 1; i < n; i++) {
    if (A[i]->a == 0) {
      A[i]->h = *H[i - 1] + 1;
      H[i] = &(A[i]->h);
    } else {
      A[i]->h = *H[i - A[i]->a];
      for (j = i; j > i - A[i]->a; j--) {
        H[j] = H[j - 1];
        (*H[j])++;
      }
      H[i - A[i]->a] = &(A[i]->h);
    }
  }
  for (i = 0; i < n; i++) {
    printf("%s %d\n", A[i]->n, A[i]->h);
  }
  return 0;
}
