#include <bits/stdc++.h>
using namespace std;
pair<int, string> a[3005];
int h[3005];
vector<pair<string, int> > ans;
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i].first > i) {
      cout << "-1\n";
      return 0;
    }
  m = h[0] = 0;
  for (int i = 1; i < n; i++)
    m = max(m, h[i] = h[i - 1] + (a[i].first > a[i - 1].first));
  for (int i = 0; i < n; i++)
    ans.insert(ans.begin() + a[i].first, make_pair(a[i].second, h[i]));
  for (int i = 0; i < n; i++)
    cout << ans[i].first << ' ' << m - ans[i].second + 1 << '\n';
  return 0;
}
