#include <bits/stdc++.h>
using namespace std;
struct b {
  int np;
  int xo;
} p[70000];
int n, val[70000], ne = 0;
queue<int> q;
int main() {
  memset(val, 0, sizeof(val));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &p[i].np, &p[i].xo);
  for (int i = 0; i < n; i++) {
    if (p[i].np == 1) {
      q.push(i);
      val[i] = 1;
    }
    ne += p[i].np;
  }
  printf("%d\n", ne / 2);
  while (!q.empty()) {
    int f = q.front();
    q.pop();
    if (p[f].np == 0) continue;
    if (p[f].np != 1) {
      q.push(f);
      continue;
    }
    if (p[f].np != 0) {
      printf("%d %d\n", f, p[f].xo);
      p[p[f].xo].xo ^= f;
      p[p[f].xo].np--;
      if (val[p[f].xo] == 0) {
        q.push(p[f].xo);
        val[p[f].xo] = 1;
      }
    }
  }
  return 0;
}
