#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.141592653589793238462;
const int nmax = 8000;
const int hash_base = 119;
const long long inf = 2e9;
int n, N[nmax], ans[nmax], sum;
pair<int, string> A[nmax];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i].second >> A[i].first;
    N[A[i].first]++;
  };
  sort(A + 1, A + n + 1);
  for (int i = 1; i <= n; i++) ans[i] = i;
  for (int i = n; i >= 1; i--) {
    sum += N[A[i].first];
    if (n - sum < A[i].first) {
      printf("-1\n");
      return 0;
    };
    int cnt = ans[i];
    while (i > 1 && A[i].first == A[i - 1].first) i--;
    ans[i - 1] = cnt + A[i].first;
    for (int j = i - 2; j >= i - (A[i].first - A[j].first) && j >= 0; j--)
      ans[j] = ans[j + 1] - 1;
  };
  for (int i = 1; i <= n; i++) cout << A[i].second << " " << ans[i] << endl;
  return 0;
}
