In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him.

After a while the cashier has a lunch break and the people in the queue seat on the chairs in the waiting room in a random order.

When the lunch break was over, it turned out that nobody can remember the exact order of the people in the queue, but everyone remembers his number ai.

Your task is to restore the order in which the people stood in the queue if it is possible. There may be several acceptable orders, but you need to find any of them. Also, you need to print a possible set of numbers hi — the heights of people in the queue, so that the numbers ai are correct.

Input

The first input line contains integer n — the number of people in the queue (1 ≤ n ≤ 3000). Then n lines contain descriptions of the people as "namei ai" (one description on one line), where namei is a non-empty string consisting of lowercase Latin letters whose length does not exceed 10 characters (the i-th person's name), ai is an integer (0 ≤ ai ≤ n - 1), that represents the number of people who are higher and stand in the queue in front of person i. It is guaranteed that all names are different.

Output

If there's no acceptable order of the people in the queue, print the single line containing "-1" without the quotes. Otherwise, print in n lines the people as "namei hi", where hi is the integer from 1 to 109 (inclusive), the possible height of a man whose name is namei. Print the people in the order in which they stand in the queue, starting from the head of the queue and moving to its tail. Numbers hi are not necessarily unique.

Examples

Input

4
a 0
b 2
c 0
d 0


Output

a 150
c 170
d 180
b 160


Input

4
vasya 0
petya 1
manya 3
dunay 3


Output

-1
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vii vector<ii>
#define vvi vector<vi>
typedef complex<double> Point;
#define X real() 
#define Y imag() 
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p0,p1)             (dp(vec(p0,p1),vec(p0,p1)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
#define polar(r,ang)            ((r)*exp(point(0,ang)))
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  	(rotateO(vec(about,p),ang)+about)
//#define x first
//#define y second
const double EPS = (1e-5);
typedef complex<double> point;
int dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1; }
// Constant PI for providing angles in radians
struct Double {
	double d;
	Double() { d = 0.0; };
	Double(double d) : d(d) {}
	bool operator < (const Double& D) const {
		return dcmp(d, D.d) < 0;
	}
	bool operator > (const Double& D) const {
		return dcmp(d, D.d) > 0;
	}
	bool operator == (const Double& D) const {
		return dcmp(d, D.d) == 0;
	}
};
bool intersectSegments(point a, point b, point c, point d, point& intersect) {
	double d1 = cp(a - b, d - c), d2 = cp(a - c, d - c), d3 = cp(a - b, a - c);
	if (fabs(d1) < EPS)
		return false;  // Parllel || identical

	double t1 = d2 / d1, t2 = d3 / d1;
	intersect = a + (b - a) * t1;

	if (t1 < -EPS || t2 < -EPS || t2 > 1 + EPS)
		return false;  //e.g ab is ray, cd is segment ... change to whatever
	return true;
}
class UnionFind { // OOP style
private: vi p, rank; // remember: vi is vector<int>
public:
	UnionFind(int N) {
		rank.assign(N, 0);
		p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i;
	}
	int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
	bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) { // if from different set
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) p[y] = x; // rank keeps the tree short
			else {
				p[x] = y;
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}
};
struct line { double a, b, c; };
long long binpowmod(long long a, long long b, long long m){a %= m;long long res = 1;while (b > 0){if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
#define sz(a) int(a.size())
#pragma GCC target ("sse4.2")
const int N = 40+10;
const int M = 50+10;
const ll INF = 1e7 + 100;
#define PI acos(-1)
#define pb push_back
#define all(s) s.begin(),s.end()
typedef double long dl;
#define MOD1 1e8
#define MOD 998244353
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
int gcd1(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}
int BIT[N];
void update(int x, int val) { ++x;  while (x <= N) { BIT[x] += val; x += (x & -x); } }
int query(int x) { ++x;  int res = 0;  while (x > 0) { res += BIT[x];  x -= (x & -x); } return res; }
void solve()
{
	int n;
	cin >> n;
	vector<pair<int, string>> v;
	for (int i = 0; i < n; ++i)
	{
		string s; int x;
		cin >> s >> x;
		v.pb({ x,s });
	}
	sort(all(v));
	for (int i = 0; i < sz(v); ++i)
	{
		int before = i;
		if (v[i].first > before)
		{
			cout << "-1\n";
			return;
		}
	}
	int st = 1;
	vector<pair<string, int>> ans;
	int want = 0;
	for (int i = sz(v) - 1; i >= 0; --i)
	{
		if (i + 1 == want)
		{
			st++;
			want = 0;
		}
		ans.pb({ v[i].second,st });
		want = max(v[i].first, want);
	}
	for (int i = sz(ans) - 1; i >= 0; --i)
		cout << ans[i].first << ' ' << ans[i].second << '\n';
}
int main(void)
{
	//freopen("cases.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//ios::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
		//if (tc)
			//cout << '\n';
	}
}