#include <bits/stdc++.h>
using namespace std;
const int N = 4000;
struct node {
  string name;
  int a;
  bool operator<(node b) const { return a < b.a; }
} p[N];
int s[N], num[N];
void out(int x) {
  cout << x;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) s[i] = i;
  for (i = 1; i <= n; i++) cin >> p[i].name >> p[i].a;
  sort(p + 1, p + n + 1);
  vector<pair<string, int> > ans;
  for (i = 1; i <= n; i++) {
    if (p[i].a >= i) out(-1);
    ans.insert(ans.begin() + p[i].a, make_pair(p[i].name, n - i + 1));
  }
  for (auto v : ans) cout << v.first << ' ' << v.second << endl;
  return 0;
}
