#include <bits/stdc++.h>
using namespace std;
struct data {
  int you, me;
};
queue<data> q;
int n, a[214321], b[214321], ans1[214321], ans2[214321], t;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    if (a[i] == 1) {
      data d;
      d.me = i;
      d.you = b[i];
      q.push(d);
    }
  }
  while (!q.empty()) {
    data u = q.front();
    q.pop();
    if (a[u.you] < 1) continue;
    t++;
    ans1[t] = u.me;
    ans2[t] = u.you;
    a[u.you]--;
    b[u.you] ^= u.me;
    a[u.me]--;
    if (a[u.you] == 1) {
      data d;
      d.me = u.you;
      d.you = b[u.you];
      q.push(d);
    }
  }
  printf("%d\n", t);
  for (int i = 1; i <= t; i++) printf("%d %d\n", ans1[i], ans2[i]);
  return 0;
}
