#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
const int M = 13;
const int K = 510;
const int LIT = 2500;
const int INF = 1 << 30;
vector<pair<int, int> > v;
int n;
string name[N];
char stmp[M];
void init() {
  v = vector<pair<int, int> >(n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%s %d", &stmp, &x);
    name[i] = stmp;
    v[i] = make_pair(x, i);
  }
  sort(v.begin(), v.end());
}
void solve() {
  vector<pair<int, int> > m;
  int h = 100000000, i;
  for (i = 0; i < n; i++) {
    if (v[i].first == 0)
      m.push_back(make_pair(v[i].second, h));
    else
      break;
  }
  for (; i < n;) {
    int j;
    for (j = i + 1; j < n; j++) {
      if (v[j].first != v[i].first) break;
    }
    j--;
    h--;
    if (m.size() < v[i].first) {
      cout << -1 << endl;
      return;
    }
    vector<pair<int, int> > tmp;
    for (int k = 0; k < v[i].first; k++) tmp.push_back(m[k]);
    for (int k = i; k <= j; k++) {
      tmp.push_back(make_pair(v[k].second, h));
    }
    for (int k = v[i].first; k < m.size(); k++) tmp.push_back(m[k]);
    m = tmp;
    i = j + 1;
  }
  for (int i = 0; i < n; i++) {
    printf("%s %d\n", name[m[i].first].c_str(), m[i].second);
  }
}
int main() {
  while (cin >> n) {
    init();
    solve();
  }
}
