#include <bits/stdc++.h>
using namespace std;
long double mod = 1000000007;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  long long v_ans[n];
  long long last[n + 10];
  memset(v_ans, 0, sizeof(v_ans));
  vector<string> mp[n + 5];
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s >> v[i];
    if (v[i] >= n) {
      cout << "-1";
      return 0;
    }
    mp[v[i]].push_back(s);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i] > i) {
      cout << "-1";
      return 0;
    }
    last[v[i]] = i;
  }
  long long cnt = 1000000;
  for (long long i = 0; i < n; i++) {
    long long mini = v[n - 1];
    for (long long j = i + 1; j < n; j++) {
      if (v[j] != v[i]) mini = min(mini, v[j]);
    }
    mini = mini - v[i];
    for (long long j = last[v[i]]; j >= 0; j--) {
      if (mini == 0) break;
      if (v_ans[j] == 0) {
        v_ans[j] = cnt;
        cnt--;
        mini--;
      }
      if (mini == 0) break;
    }
    i = last[v[i]];
  }
  for (long long i = n - 1; i >= 0; i--) {
    if (v_ans[i] == 0) {
      v_ans[i] = cnt;
      cnt--;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << mp[v[i]][mp[v[i]].size() - 1] << " ";
    mp[v[i]].pop_back();
    cout << v_ans[i] << endl;
  }
  return 0;
}
