#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
pair<string, int> p[3333];
int r[3333], cr[3333], n;
int comp(pair<string, int> i, pair<string, int> j) {
  return i.second < j.second;
}
int main() {
  cin >> n;
  for (int(i) = (0); (i) < (n); (i)++) cin >> p[i].first >> p[i].second;
  sort(p, p + n, comp);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (p[i].second > v.size()) {
      puts("-1");
      return 0;
    }
    v.insert(v.begin() + p[i].second, i);
  }
  for (int i = 0; i < n; i++) {
    r[v[i]] = n - i;
  }
  for (int i = 0; i < n; i++) cout << p[i].first << " " << r[i] << endl;
  return 0;
}
