#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
pair<string, int> PEOPLE[maxn];
int p[maxn];
int k[maxn];
int hight[maxn];
int cnt = 1;
bool cmp(pair<string, int> A, pair<string, int> B) {
  return A.second < B.second;
}
void check(int len) {
  for (int i = 1; i <= len; i++) printf("%d ", p[i]);
  printf("\n");
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> PEOPLE[i].first >> PEOPLE[i].second;
  sort(PEOPLE + 1, PEOPLE + 1 + n, cmp);
  if (PEOPLE[1].second > 0) {
    cout << "-1" << endl;
    return 0;
  }
  hight[1] = 1;
  p[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (i <= PEOPLE[i].second) {
      printf("-1\n");
      return 0;
    }
    for (int j = i - 1; j >= i - PEOPLE[i].second; j--) {
      p[j + 1] = p[j];
    }
    p[i - PEOPLE[i].second] = i;
  }
  for (int i = 1; i <= n; i++) {
    k[p[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cout << PEOPLE[i].first << " " << k[i] << endl;
  }
  return 0;
}
