#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<pair<int, string> > q;
  vector<pair<int, int> > res;
  scanf("%d", &n);
  for (int i = 0, t; i < n; i++) {
    string r;
    cin >> r >> t;
    q.push_back(make_pair(t, r));
  }
  sort(q.begin(), q.end());
  int flag = 1;
  res.push_back(make_pair(10000, 0));
  q[0].first = 10000;
  for (int i = 1; i < n; i++) {
    if (q[i].first > res.size()) {
      flag = 0;
      break;
    }
    for (int j = q[i].first; j < res.size(); j++)
      q[res[j].second].first++, res[j].first++;
    if (q[i].first)
      res.push_back(make_pair(res[q[i].first - 1].first + 1, i)),
          q[i].first = res[q[i].first - 1].first + 1;
    else
      res.push_back(make_pair(res[0].first - 1, i)),
          q[i].first = res[0].first - 1;
    sort(res.begin(), res.end());
  }
  if (!flag)
    puts("-1");
  else {
    for (int i = 0; i < n; i++)
      cout << q[i].second << ' ' << 20000 - q[i].first << endl;
  }
  return 0;
}
