#include <bits/stdc++.h>
using namespace std;
struct data {
  int v, s, num;
} a[100000];
queue<int> c;
struct data2 {
  int x, y;
};
queue<data2> q;
int cmp(struct data p, struct data q) {
  if (p.num < q.num)
    return 1;
  else
    return 0;
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].num, &a[i].s);
    a[i].v = i;
    if (a[i].num == 1) c.push(a[i].v);
  }
  while (!c.empty()) {
    int top = c.front();
    c.pop();
    if (a[top].num == 1) {
      data2 ne;
      ne.x = top - 1;
      ne.y = a[top].s;
      q.push(ne);
      a[a[top].s + 1].num--;
      a[a[top].s + 1].s ^= (top - 1);
      if (a[a[top].s + 1].num == 1) c.push(a[top].s + 1);
    }
  }
  printf("%d\n", q.size());
  while (!q.empty()) {
    data2 tt;
    tt = q.front();
    q.pop();
    printf("%d %d\n", tt.x, tt.y);
  }
}
