#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, hav[(1 << 20)], x[(1 << 20)];
int q[(1 << 20)];
int xx[(1 << 20)], yy[(1 << 20)], tp;
int main() {
  n = read();
  for (int i = 0; i <= n - 1; i++) {
    hav[i] = read();
    x[i] = read();
  }
  tp = 0;
  int h = 0, t = -1;
  for (int i = 0; i <= n - 1; i++)
    if (hav[i] == 1) q[++t] = i;
  while (h <= t) {
    int u = q[h++];
    if (hav[u] == 0) continue;
    x[x[u]] ^= u;
    hav[x[u]]--;
    tp++;
    xx[tp] = u;
    yy[tp] = x[u];
    if (hav[x[u]] == 1) q[++t] = x[u];
  }
  cout << tp << endl;
  for (int i = 1; i <= tp; i++) printf("%d %d\n", xx[i], yy[i]);
  puts("");
  return 0;
}
