Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approaching fast, he is doing book exercises day and night. He writes down and keeps updating the remaining number of exercises on the back cover of each book.
Harry has a lot of books messed on the floor. Therefore, he wants to pile up the books that still have some remaining exercises into a single pile. He will grab the books one-by-one and add the books that still have remaining exercises to the top of the pile.
Whenever he wants to do a book exercise, he will pick the book with the minimum number of remaining exercises from the pile. In order to pick the book, he has to remove all the books above it. Therefore, if there are more than one books with the minimum number of remaining exercises, he will take the one which requires the least number of books to remove. The removed books are returned to the messy floor. After he picks the book, he will do all the remaining exercises and trash the book.
Since number of books is rather large, he needs your help to tell him the number of books he must remove, for picking the book with the minimum number of exercises.

Note that more than one book can have the same name.

-----Input-----
The first line contains a single integer N denoting the number of actions. Then N lines follow. Each line starts with an integer. If the integer is -1, that means Harry wants to do a book exercise. Otherwise, the integer is number of the remaining exercises in the book he grabs next. This is followed by a string denoting the name of the book.

-----Output-----
For each -1 in the input, output a single line containing the number of books Harry must remove, followed by the name of the book that Harry must pick.

-----Constraints-----

1 < N ≤ 1,000,000
0 ≤ (the number of remaining exercises of each book) < 100,000
The name of each book consists of between 1 and 15 characters 'a' - 'z'.
Whenever he wants to do a book exercise, there is at least one book in the pile.

-----Example-----
Input:
6
9 english
6 mathematics
8 geography
-1
3 graphics
-1

Output:
1 mathematics
0 graphics

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
t = eval(input())
a = []
b = []
top = -1
for __ in range(0, t):
	x = input().split()
	if x[0] != '-1' and x[0] != '0':
		add = int(x[0])
		if top != -1 and add > a[top][0]:
			b[top] += 1
		else:
			a.append((add, x[1]))
			b.append(0)
			top += 1
	elif x[0] == '-1':
		print(b[top], end=' ')
		print(a[top][1])
		foo = a.pop()
		bar = b.pop()
		top -= 1


import sys
N = eval(input())
ignore = [0]
name = []
arr = []
cname = cignore = 0
x = sys.stdin.readline().split()
arr.append(int(x[0]))
name.append(x[1])
for xyz in range(N - 1):
	x = sys.stdin.readline().split()
	if x[0] != '-1' and x[0] != '0':
		if cname == -1 or int(x[0]) <= arr[cname]:
			ignore.append(0)
			cignore = cignore + 1
			cname = cname + 1
			name.append(x[1])
			arr.append(int(x[0]))
		else:
			ignore[cignore] = ignore[cignore] + 1
	elif x[0] == '-1':
		aman = arr.pop()
		cignore = cignore - 1
		cname = cname - 1
		print(ignore.pop(), name.pop())


test = eval(input())
a = []
b = []
c = 0
top = -1
for i in range(test):
	x = input().split()
	if x[0] != '-1' and x[0] != '0':
		add = int(x[0])
		if top != -1 and add > a[top][0]:
			b[top] += 1
		else:
			a.append((add, x[1]))
			b.append(0)
			top += 1
	elif x[0] == '-1':
		print('%s %s' % (b[top], a[top][1]))
		xx = a.pop()
		t = b.pop()
		top -= 1


test = eval(input())
exer_book = []
min_stack = []
top = -1
for i in range(test):
	s = input().split()
	if s[0] != '-1' and s[0] != '0':
		n = int(s[0])
		if top >= 0 and n > exer_book[top][0]:
			min_stack[top] += 1
		else:
			exer_book.append((n, s[1]))
			min_stack.append(0)
			top += 1
	elif s[0] == '-1':
		print('%s %s' % (min_stack[top], exer_book[top][1]))
		exer_book.pop()
		min_stack.pop()
		top -= 1


test = eval(input())
a = []
b = []
top = -1
for i in range(test):
	x = input().split()
	if x[0] != '-1' and x[0] != '0':
		n = int(x[0])
		if top > -1 and n > a[top][0]:
			b[top] += 1
		else:
			a.append((n, x[1]))
			b.append(0)
			top += 1
	elif x[0] == '-1':
		print('%s %s' % (b[top], a[top][1]))
		a.pop()
		b.pop()
		top -= 1


import sys
n = int(sys.stdin.readline())
book_stack = [[999999, 'NAME', 0]]
length = 0
while n:
	inp = sys.stdin.readline().strip()
	if inp == '-1':
		print(str(book_stack[length][2]) + ' ' + book_stack[length][1])
		del book_stack[length]
		length -= 1
	else:
		(value, name) = inp.split()
		value = int(value)
		if value != 0:
			if value > book_stack[length][0]:
				book_stack[length][2] += 1
			else:
				book_stack.append([value, name, 0])
				length += 1
	n -= 1