#include <bits/stdc++.h>
const int N = 65550;
int ru[N], sum[N];
int n;
int s[N], t[N], cc = 0;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d%d", &ru[i], &sum[i]);
  for (i = 0; i < n; i++) {
    int now = i;
    while (ru[now] == 1) {
      cc++;
      s[cc] = now;
      t[cc] = sum[now];
      ru[now]--;
      ru[sum[now]]--;
      sum[sum[now]] ^= now;
      now = sum[now];
    }
  }
  printf("%d\n", cc);
  for (i = 1; i <= cc; i++) printf("%d %d\n", s[i], t[i]);
  return 0;
}
