#include <bits/stdc++.h>
using namespace std;
int n, d[200000], s[200000], q[200000], rx[200000], ry[200000];
int st, ed, t;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d%d", &d[i], &s[i]);
  for (int i = (0); i < (n); i++)
    if (d[i] == 1) q[++ed] = i;
  st = 1;
  while (st <= ed) {
    int x = q[st++];
    if (!d[x]) continue;
    int p = s[x];
    d[p]--;
    s[p] ^= x;
    rx[t] = p;
    ry[t++] = x;
    if (d[p] == 1) q[++ed] = p;
  }
  printf("%d\n", t);
  for (int i = (0); i < (t); i++) printf("%d %d\n", rx[i], ry[i]);
  return 0;
}
