#include <bits/stdc++.h>
const int N = (1 << 16) + 1;
int leaf[N], degree[N], s[N];
int main(int argc, char *argv[]) {
  int n, i, cnt, index, adj, sum = 0;
  scanf("%d", &n);
  cnt = 0;
  for (i = 0; i < n; ++i) {
    scanf("%d%d", &degree[i], &s[i]);
    sum += degree[i];
    if (1 == degree[i]) {
      leaf[cnt++] = i;
    }
  }
  printf("%d\n", sum / 2);
  while (cnt > 1) {
    index = leaf[--cnt];
    if (degree[index] != 1) {
      continue;
    }
    adj = s[index];
    printf("%d %d\n", index, adj);
    --degree[adj];
    s[adj] ^= index;
    if (1 == degree[adj]) {
      leaf[cnt++] = adj;
    }
  }
  return EXIT_SUCCESS;
}
