#include <bits/stdc++.h>
using namespace std;
struct Node {
  int deg, sum;
  int now;
} node[70000];
struct Edge {
  int u, v;
  int next;
} edge[70000];
int head[70000], tot;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void add(int u, int v) {
  edge[tot].u = u;
  edge[tot].v = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
int main(int argc, char *argv[]) {
  int n, i, u, v, cnt;
  while (~scanf("%d", &n)) {
    cnt = 0;
    for (i = 0; i < n; ++i) {
      scanf("%d%d", &node[i].deg, &node[i].sum);
      node[i].now = 0;
      cnt += node[i].deg;
    }
    printf("%d\n", cnt / 2);
    init();
    for (i = 0; i < n; ++i) {
      u = i;
      while (node[u].deg == 1) {
        v = node[u].sum ^ node[u].now;
        printf("%d %d\n", u, v);
        node[v].now ^= u;
        node[v].deg--;
        node[u].deg--;
        u = v;
      }
    }
  }
  return 0;
}
