#include <bits/stdc++.h>
using namespace std;
pair<int, string> arr[3500];
int cnt[3500], h[3500], v[3500];
void upd(int p, int n) {
  for (int i = p; i < n; ++i) cnt[i] += 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].second >> arr[i].first;
    cnt[i] = 0;
    v[i] = 0;
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; ++i) {
    if (arr[i].first > i) {
      puts("-1");
      return 0;
    }
  }
  reverse(arr, arr + n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < n; ++j) {
      int empty_pos = n - j - cnt[n - 1] + cnt[j] - 1;
      if (arr[j].first == empty_pos && !v[j]) {
        v[j] = 1;
        upd(j, n);
        h[j] = i;
        break;
      }
    }
  }
  for (int i = n - 1; i >= 0; --i) cout << arr[i].second << " " << h[i] << endl;
  return 0;
}
