#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(int a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(int a) {
  write(a);
  puts("");
}
int n;
const int N = 200005;
struct data {
  int du, xo;
} a[N];
int que[N], l, r, an[N], ans;
int main() {
  n = read();
  for (int i = 0; i < n; i++) {
    a[i].du = read();
    a[i].xo = read();
  }
  for (int i = 0; i < n; i++) {
    if (a[i].du == 1) que[++r] = i;
  }
  while (l++ < r) {
    int k = que[l];
    if (a[k].du) {
      if (--a[a[k].xo].du == 1) que[++r] = a[k].xo;
      a[a[k].xo].xo ^= k;
      an[++ans] = k;
      an[++ans] = a[k].xo;
    }
  }
  writeln(ans / 2);
  for (int i = 1; i <= ans; i += 2) {
    write(an[i]);
    putchar(' ');
    writeln(an[i + 1]);
  }
}
