#include <bits/stdc++.h>
using namespace std;
const int N = 4000;
struct node {
  string name;
  int a;
  bool operator<(node b) const { return a < b.a; }
} p[N];
int s[N], num[N];
void out(int x) {
  cout << x;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) s[i] = i;
  for (i = 1; i <= n; i++) cin >> p[i].name >> p[i].a;
  sort(p + 1, p + n + 1);
  for (i = n; i >= 1; i--) {
    int last = p[i].a - num[i];
    if (last == 0) continue;
    bool flag;
    if (last < 0)
      flag = 0;
    else
      flag = 1;
    if (flag) {
      priority_queue<pair<int, int> > que;
      for (j = 1; j < i; j++) que.push(make_pair(s[j], j));
      while (!que.empty() && last != 0) {
        int look = que.top().first;
        if (que.top().first < s[i]) {
          j = que.top().second;
          last--;
        }
        que.pop();
      }
    } else {
      priority_queue<pair<int, int>, vector<pair<int, int> >,
                     greater<pair<int, int> > >
          que;
      for (j = 1; j < i; j++) que.push(make_pair(s[j], j));
      while (!que.empty() && last != 0) {
        int look = que.top().first;
        if (que.top().first > s[i]) {
          j = que.top().second;
          last++;
        }
        que.pop();
      }
    }
    if (last != 0)
      out(-1);
    else {
      for (int k = j + 1; k <= i - 1; k++) {
        if (s[j] > s[k] && s[i] < s[k]) num[k]--;
        if (s[j] < s[k] && s[i] > s[k]) num[k]++;
      }
      swap(s[i], s[j]);
      num[j] = 0;
      for (int k = 1; k < j; k++)
        if (s[k] > s[j]) num[j]++;
    }
  }
  for (i = 1; i <= n; i++) cout << p[i].name << ' ' << s[i] << endl;
  return 0;
}
