#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e5 + 10;
pair<int, int> arr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, string>> v, ans(n);
  for (int i = 0; i < n; i++) {
    string s;
    int a;
    cin >> s >> a;
    v.push_back({a, s});
  }
  sort(v.begin(), v.end());
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    if (v[i].first == 0) {
      arr[i].first = cnt++;
      arr[i].second = i;
    } else {
      if (i < v[i].first) {
        puts("-1");
        return 0;
      } else {
        int pnt = v[i].first, indx = i;
        while (pnt--) {
          arr[indx - 1].first++;
          arr[indx] = arr[indx - 1];
          indx--;
        }
        arr[indx].first = arr[indx + 1].first - 1;
        arr[indx].second = i;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ans[arr[i].second] = make_pair(arr[i].first, v[arr[i].second].second);
  }
  for (auto it : ans) cout << it.second << " " << it.first << '\n';
  return 0;
}
