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.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;

public class CF1_285A {
    
    static Reader sc = new Reader();
    static PrintWriter out = new PrintWriter(System.out); 
    
    public static void main(String[] args) throws IOException {             
        int n = sc.nextInt();
        
        PriorityQueue<Pair<Integer, Integer>> PQ = new PriorityQueue<Pair<Integer, Integer>>();
        int[] deg = new int[n];
        int[] xor = new int[n];
        int[] curDeg = new int[n];
        
        for (int i = 0; i < n; i++) {
            deg[i] = sc.nextInt();
            curDeg[i] = deg[i];
            xor[i] = sc.nextInt();
            PQ.add(new Pair(deg[i], i));
        }
        
        ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
        
        for (int i = 0; i < n; i++) {
            adj.add(new ArrayList<Integer>());
        }
        
        while(!PQ.isEmpty()) {
            Pair<Integer, Integer> actt = PQ.poll();
            int degAct =  actt.first;
            int node = actt.second;
                        
            if(degAct > curDeg[node])
                continue;
            
            if(degAct == 1) {
                int accumXor = 0;
                int i = xor[node];
                
                if(i != node) {
                    adj.get(node).add(i);
                    adj.get(i).add(node);                       
                    curDeg[i]--;
                    curDeg[node]--;
                    xor[i] ^= node;
                    PQ.add(new Pair(curDeg[i], i));             
                }
            }
        }
        
        ArrayList<Pair<Integer, Integer>> res = new ArrayList<Pair<Integer, Integer>>();
        
        for (int i = 0; i < n; i++) {
            for (int j : adj.get(i)) {
                if(i < j) {
                    res.add(new Pair(i,j));
                }
            }
        }
        
        out.println(res.size());
        for (Pair<Integer, Integer> p : res)
            out.println(p.first+" "+p.second);
        
        out.close();
    }
    
    static public class Pair<U, V> implements Comparable<Pair<U, V>> {
        public final U first;
        public final V second;

        public Pair(U first, V second) {
            this.first = first;
            this.second = second;
        }

        @SuppressWarnings("unchecked")
        public int compareTo(Pair<U, V> other) {            
            int value = ((Comparable<U>)this.first).compareTo(other.first);
            if (value != 0)
                return value;
            return ((Comparable<V>)this.second).compareTo(other.second);
        }

        public boolean equals(Pair<U, V> other) {
            return (this.compareTo(other) == 0);                
        }

        @Override
        public int hashCode() {
            return 31 * (527 + first.hashCode()) + second.hashCode();
        }

        @Override
        public String toString() {
            return "(" + first + ", " + second + ")";
        }
    }
    
    static class Reader {
        final private int BUFFER_SIZE = 1 << 12;private byte[] buffer;private int bufferPointer, bytesRead;
        public Reader(){buffer=new byte[BUFFER_SIZE];bufferPointer=bytesRead=0;
        }private void fillBuffer() throws IOException{bytesRead=System.in.read(buffer,bufferPointer=0,BUFFER_SIZE);if(bytesRead==-1)buffer[0]=-1;
        }private byte read() throws IOException{if(bufferPointer==bytesRead)fillBuffer();return buffer[bufferPointer++];
        }public String next() throws IOException{StringBuilder sb = new StringBuilder();byte c;while((c=read())<=' '){if(c==-1) return null;};do{sb.append((char)c);}while((c=read())>' ');if (sb.length()==0) return null;return sb.toString();
        }public String nextLine() throws IOException{StringBuilder sb = new StringBuilder();byte c;boolean read = false;while((c=read())!=-1){if(c=='\n') {read = true;break;}if(c>=' ')sb.append((char)c);}if (!read) return null;return sb.toString();
        }public int nextInt() throws IOException{int ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
        }public long nextLong() throws IOException{long ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10L+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
        }public double nextDouble() throws IOException{double ret=0,div=1;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c = read();do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(c=='.')while((c=read())>='0'&&c<='9')ret+=(c-'0')/(div*=10);if(neg)return -ret;return ret;
        }public int[] na(int n) throws IOException{int[] a = new int[n];for(int i = 0;i < n;i++)a[i] = nextInt();return a;
        }public char[][] ncha(int n) throws IOException{char[][] a = new char[n][];for(int i = 0;i < n;i++)a[i] = next().toCharArray();return a;
        }public int[][] nm(int n, int m) throws IOException{int[][] map = new int[n][m];for(int i = 0;i < n;i++)map[i] = na(m);return map;
        }public void close() throws IOException{if(System.in==null) return;System.in.close();}
    }
    
    static void print(int[] A) {for(int i=0;i<A.length;i++){if(i!=0) out.print(' ');out.print(A[i]);}out.println();}
    static <T> void print(Iterable<T> A) {int i = 0;for(T act : A){if(i!=0)out.print(' ');out.print(act);i++;}out.println();}
    static void printPlus1(Iterable<Number> A) {int i = 0;for(Number act : A){if(i!=0)out.print(' ');out.print(act.longValue() + 1L);i++;}out.println();}
    static void debug(Object... o) { System.err.println(Arrays.deepToString(o)); }
    
    /*
    long s = System.currentTimeMillis();
    debug(System.currentTimeMillis()-s+"ms");
     */
}
