Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degree_{v} and s_{v}, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). 

Next day Misha couldn't remember what graph he initially had. Misha has values degree_{v} and s_{v} left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 2^16), the number of vertices in the graph.

The i-th of the next lines contains numbers degree_{i} and s_{i} (0 ≤ degree_{i} ≤ n - 1, 0 ≤ s_{i} < 2^16), separated by a space.


-----Output-----

In the first line print number m, the number of edges of the graph.

Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b).

Edges can be printed in any order; vertices of the edge can also be printed in any order.


-----Examples-----
Input
3
2 3
1 0
1 0

Output
2
1 0
2 0

Input
2
1 1
1 0

Output
1
0 1



-----Note-----

The XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".

Difficulty: MEDIUM

Solutions:
n = int(input())
l = []
stack = []
for i in range(n):
	(d, s) = map(int, input().split())
	if d == 1:
		stack.append(i)
	l.append([d, s])
c = 0
edges = ''
while stack:
	i = stack.pop(0)
	(d, s) = l[i]
	if d == 0:
		continue
	(dd, ss) = l[s]
	if dd == 2:
		stack.append(s)
	l[s] = [dd - 1, ss ^ i]
	edges += str(i) + ' ' + str(s) + '\n'
	c += 1
print(c)
print(edges)


from collections import deque
n = int(input())
process = deque()
vs = []
for i in range(n):
	(d, s) = list(map(int, input().split()))
	if d == 1:
		process.append(i)
	vs.append((d, s))
edges = []
while process:
	a = process.popleft()
	(d, s) = vs[a]
	if d == 0:
		continue
	(dd, ss) = vs[s]
	vs[s] = (dd - 1, ss ^ a)
	if dd == 2:
		process.append(s)
	edges.append((a, s))
print(len(edges))
for (a, b) in edges:
	print(a, b)


from sys import stdin, stdout, setrecursionlimit
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq
n = it()
v = []
for _ in range(n):
	v.append(mp())
q = deque()
for i in range(n):
	if v[i][0] == 1:
		q.append(i)
ans = []
while q:
	ver = q.popleft()
	if not v[ver][0]:
		continue
	ans.append([ver, v[ver][1]])
	v[v[ver][1]][0] -= 1
	v[v[ver][1]][1] ^= ver
	if v[v[ver][1]][0] == 1:
		q.append(v[ver][1])
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


import os
import sys
from io import BytesIO, IOBase
from collections import deque

def main():
	n = int(input())
	arr = []
	q = deque()
	for _ in range(n):
		(a, b) = map(int, input().split())
		arr.append([a, b])
		if a == 1:
			q.append(_)
	ans = []
	while q:
		x = q.popleft()
		if arr[x][0] == 1:
			ans.append((x, arr[x][1]))
		else:
			continue
		y = arr[x][1]
		arr[y][0] -= 1
		arr[y][1] ^= x
		if arr[y][0] == 1:
			q.append(y)
	print(len(ans))
	for _ in ans:
		print(*_)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from queue import Queue as Q
q = Q()
(n,) = I()
l = []
x = [0] * (n + 10)
d = [0] * (n + 10)
for i in range(n):
	(a, b) = I()
	x[i] = b
	d[i] = a
	if a == 1:
		q.put(i)
e = []
while not q.empty():
	p = q.get()
	par = x[p]
	if d[p] == 1:
		if p != par:
			e.append([p, par])
		x[par] ^= p
		d[par] -= 1
		d[p] -= 1
		if d[par] == 1:
			q.put(par)
print(len(e))
for i in e:
	if i[0] != i[1]:
		print(*i)