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, degreev and sv, 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 degreev and sv 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 ≤ 216), the number of vertices in the graph.

The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si < 216), 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".
import java.util.*;
import java.io.*;
public class Q3 {

	static ArrayList<Integer> adj[];
	static int color[],red[],black[],previs[];
	static boolean b[],visited[],possible;
	static Map<Long,Long> dict;
	static int totalnodes,colored,time;
	
	
	void solve(){
		
		
		in=new InputReader(System.in);
		out=new PrintWriter(System.out);
		int n=in.nextInt();
		dict=new HashMap<>();
		HashSet<Pair> hs=new HashSet<>();
		Queue<Integer> q=new LinkedList<Integer>();
		int degree[]=new int[n];
		int sum[]=new int[n];
		for(int i=0;i<n;i++)
		{
			int d=in.nextInt();
			int s=in.nextInt();
			degree[i]=d;
			sum[i]=s;
			if(degree[i]==1)
				q.add(i);
		}
		while(!q.isEmpty())
		{
			int leaf=q.poll();
			//debug("leaf "+leaf);
			int parent=sum[leaf];
			if(degree[leaf]==0)
				continue;
		//	debug("parent "+parent);
			degree[leaf]--;
			//System.out.println(parent);
			sum[parent]^=leaf;
			sum[leaf]=0;
			degree[parent]--;
			
			if(leaf!=parent)
			hs.add(new Pair(leaf,parent));
			//debug("degp "+degree[parent]);
			if(degree[parent]==1)
				q.add(parent);
		}
		out.println(hs.size());
		for(Pair p:hs)
		{
			out.println(p.u+" "+p.v);
		}
		out.close();
				
	}
	  int dfs_red(int i)
	{
		previs[i]=time++;
		visited[i]=true;
		if(color[i]==0)
			red[i]++;
		for(int j:adj[i])
		{
			if(!visited[j])
				red[i]+=dfs_red(j);
		}
		return red[i];
	}
	 int dfs_black(int i)
	{
		
		visited[i]=true;
		if(color[i]==1)
			black[i]++;
		for(int j:adj[i])
		{
			if(!visited[j])
				black[i]+=dfs_black(j);
		}
		return black[i];
	}
	public static void main(String[] args) throws IOException{
		new Q3().solve();
	}
	
	 public static class dsu
		{
			 
			int n;
			int parent[];
		    int s[];
			dsu(int n)
			{
				this.n=n;
				parent=new int[n+1];
				s=new int[n+1];
		        for(int i=0;i<=n;i++)
		        {
		            parent[i]=i;
		            s[i]=1;
		        }
			}
		 int find(int i)
		{
		    if (parent[i] == i)
		        return i;
		    else
		    {
		    	int result = find(parent[i]);
		        parent[i] = result;
		        return result;
		     }
		}
		}
	static InputReader in;
	static PrintWriter out;
	public static void seive(long n){
		b = new boolean[(int) (n+1)];
		Arrays.fill(b, true);
		for(int i = 2;i*i<=n;i++){
			if(b[i]){
				for(int p = 2*i;p<=n;p+=i){
					b[p] = false;
				}
			}
		}
	}
	public static long power(long a,long b,long c)
	{
		long ans = 1;
		while(b!=0)
		{
			if(b%2==1)
			{
				ans = ans*a;
				ans = ans % c;
			}
			a = a*a;
			a = a%c;
			b = b/2;
		}
		return ans;
	}
	static class Pair implements Comparable<Pair> {
		int u,v,w;
		
		public Pair(){
			
		}
		public Pair(int u,int v) {
			this.u=u;
			this.v=v;
			this.w=Math.min(u, v);
			
		}
		public int compareTo(Pair other) {
			
			int o=Math.min(other.u,other.v)-Math.min(other.u/2, other.v);	
			int p=Math.min(this.u,this.v)-Math.min(this.u/2, this.v);
			return o-p;
		}
		
		/*public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}*/
	}
	static class Node2{
		Node2 left = null;
		Node2 right = null;
		Node2 parent = null;
		int data;
	}
	
	//binaryStree
	static class BinarySearchTree{
		Node2 root = null;
		int height = 0;
		int max = 0;
		int cnt = 1;
		ArrayList<Integer> parent = new ArrayList<>();
		HashMap<Integer, Integer> hm = new HashMap<>();
		public void insert(int x){
			Node2 n = new Node2();
			n.data = x;
			if(root==null){
				root = n;
			}
			else{
				Node2 temp = root,temp2 = null;
				while(temp!=null){
					temp2 = temp;
					if(x>temp.data) temp = temp.right;
					else temp = temp.left;
				}
				if(x>temp2.data) temp2.right = n;
				else temp2.left = n;
				n.parent = temp2;
				parent.add(temp2.data);
			}
		}
		public Node2 getSomething(int x, int y, Node2 n){
			if(n.data==x || n.data==y) return n;
			else if(n.data>x && n.data<y) return n;
			else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
			else return getSomething(x,y,n.left);
		}
		public Node2 search(int x,Node2 n){
			if(x==n.data){
				max = Math.max(max, n.data);
				return n;
			}
			if(x>n.data){
				max = Math.max(max, n.data);
				return search(x,n.right);
			}
			else{
				max = Math.max(max, n.data);
				return search(x,n.left);
			}
		}
		public int getHeight(Node2 n){
			if(n==null) return 0;
			height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
			return height;
		}
	}
public static void debug(Object... o) {
	System.out.println(Arrays.deepToString(o));
}

public static String rev(String s)
{
	StringBuilder sb=new StringBuilder(s);
	sb.reverse();
	return sb.toString();
}

static long lcm(long a, long b)
{
    return a * (b / gcd(a, b));
}

static long gcd(long a, long b)
{
    while (b > 0)
    {
        long temp = b;
        b = a % b; // % is remainder
        a = temp;
    }
    return a;
}

public static long max(long x, long y, long z){
		if(x>=y && x>=z) return x;
		if(y>=x && y>=z) return y;
		return z;
	}
	static int[] sieve(int n,int[] arr)
	{
	for(int i=2;i*i<=n;i++)
	{
		if(arr[i]==0)
		{
			for(int j=i*2;j<=n;j+=i)
				arr[j]=1;
		}
	}
	return arr;
	}




static class InputReader {

private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;

public InputReader(InputStream stream) {
  this.stream = stream;
}

public int snext() {
  if (snumChars == -1)
    throw new InputMismatchException();
  if (curChar >= snumChars) {
    curChar = 0;
    try {
      snumChars = stream.read(buf);
    } catch (IOException e) {
      throw new InputMismatchException();
    }
    if (snumChars <= 0)
      return -1;
  }
  return buf[curChar++];
}

public int nextInt() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  int sgn = 1;
  if (c == '-') {
    sgn = -1;
    c = snext();
  }
  int res = 0;
  do {
    if (c < '0' || c > '9')
      throw new InputMismatchException();
    res *= 10;
    res += c - '0';
    c = snext();
  } while (!isSpaceChar(c));
  return res * sgn;
}

public long nextLong() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  int sgn = 1;
  if (c == '-') {
    sgn = -1;
    c = snext();
  }
  long res = 0;
  do {
    if (c < '0' || c > '9')
      throw new InputMismatchException();
    res *= 10;
    res += c - '0';
    c = snext();
  } while (!isSpaceChar(c));
  return res * sgn;
}

public int[] nextIntArray(int n) {
	 return nextIntArray(n, 0);
	    }
	    
public int[] nextIntArray(int n, int off) {
	 int[] arr = new int[n + off];
	   for (int i = 0; i < n; i++) {
	    arr[i + off] = nextInt();
	    }
	    return arr;
	    }
	    
public long[] nextLongArray(int n) {
return nextLongArray(n, 0);
	    }
        
	public long[] nextLongArray(int n, int off) {
	 long[] arr = new long[n + off];
	 for (int i = 0; i < n; i++) {
		  arr[i + off] = nextLong();
		 }
 return arr;
	}


public String readString() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  StringBuilder res = new StringBuilder();
  do {
    res.appendCodePoint(c);
    c = snext();
  } while (!isSpaceChar(c));
  return res.toString();
}

public String nextLine() {
  int c = snext();
  while (isSpaceChar(c))
    c = snext();
  StringBuilder res = new StringBuilder();
  do {
    res.appendCodePoint(c);
    c = snext();
  } while (!isEndOfLine(c));
  return res.toString();
}

public boolean isSpaceChar(int c) {
  if (filter != null)
    return filter.isSpaceChar(c);
  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

private boolean isEndOfLine(int c) {
  return c == '\n' || c == '\r' || c == -1;
}

public interface SpaceCharFilter {
  public boolean isSpaceChar(int ch);
}
}
	
}
