#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v, v1;
priority_queue<pair<int, int> > que;
string s[3005];
long long arr[100005];
int main() {
  int n, x, steps;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> x;
    v.push_back(make_pair(x, i));
  }
  sort(v.begin(), v.end());
  x = 1;
  for (int i = 0; i < n; i++) {
    steps = v[i].first;
    if (steps == 0) {
      que.push(make_pair(x, v[i].second));
      x++;
      continue;
    }
    if (steps > que.size()) {
      cout << -1 << endl;
      return 0;
    }
    queue<pair<int, int> > temp;
    while (steps) {
      steps--;
      pair<int, int> p;
      p = que.top();
      que.pop();
      x = p.first;
      p.first++;
      temp.push(make_pair(p.first, p.second));
    }
    que.push(make_pair(x, v[i].second));
    while (temp.size()) {
      que.push(make_pair(temp.front().first, temp.front().second));
      temp.pop();
    }
  }
  v1.clear();
  while (que.size()) {
    arr[que.top().second] = que.top().first;
    que.pop();
  }
  for (int i = 0; i < n; i++) {
    cout << s[v[i].second] << ' ' << arr[v[i].second] << endl;
  }
  return 0;
}
