#include <bits/stdc++.h>
using namespace std;
struct NODE {
  int id, in, num;
} node[70000];
struct EDGE {
  int a, b;
} edge[70000];
int cmp(NODE a, NODE b) { return a.in < b.in; }
int main() {
  int m, n, i, j, t1, t2, cnt;
  while (cin >> n) {
    m = n;
    cnt = 0;
    queue<int> Q;
    for (i = 0; i < n; i++) {
      scanf("%d %d", &t1, &t2);
      node[i].id = i;
      node[i].in = t1;
      node[i].num = t2;
      if (t1 == 1) Q.push(i);
      if (node[i].in == 0) m--;
    }
    int tt;
    while (!Q.empty()) {
      tt = Q.front();
      if (node[tt].in == 1) {
        edge[cnt].a = node[tt].id;
        edge[cnt].b = node[tt].num;
        cnt++;
        node[node[tt].num].in--;
        node[node[tt].num].num ^= node[tt].id;
        if (node[node[tt].num].in == 1) Q.push(node[tt].num);
      }
      Q.pop();
    }
    printf("%d\n", cnt);
    for (i = 0; i < cnt; i++) {
      printf("%d %d\n", edge[i].a, edge[i].b);
    }
  }
  return 0;
}
