#include <bits/stdc++.h>
using namespace std;
int oo = (int)1e9;
const int MX = 1;
int main() {
  int n;
  vector<pair<int, string> > vs;
  cin >> n;
  string name;
  int a;
  for (int i = 0; i < n; ++i) {
    cin >> name >> a;
    vs.push_back(make_pair(a, name));
  }
  sort(vs.begin(), vs.end());
  vector<pair<string, int> > talls;
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (vs[i].first > (int)talls.size()) {
      cout << -1 << endl;
      return 0;
    }
    if (vs[i].first == (int)talls.size()) {
      for (int j = 0; j < (int)talls.size(); ++j) talls[j].second++;
      talls.push_back(make_pair(vs[i].second, 1));
    } else {
      set<pair<int, int> > st;
      for (int j = 0; j < (int)talls.size(); ++j) {
        st.insert(make_pair(talls[j].second, j));
      }
      vector<pair<int, int> > vpi(st.rbegin(), st.rend());
      int sc = vpi[vs[i].first].first + 1;
      for (int j = 0; j < vs[i].first; ++j) {
        talls[vpi[j].second].second++;
      }
      talls.push_back(make_pair(vs[i].second, sc));
    }
  }
  for (int i = 0; i < (int)talls.size(); ++i) {
    cout << talls[i].first << " " << talls[i].second << endl;
  }
  return 0;
}
