#include <bits/stdc++.h>
int deg[100000];
int xr[100000];
int edges[100000][2];
int main() {
  int n, t = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &deg[i], &xr[i]);
  }
  for (int i = 0; i < n; i++) {
    if (deg[i] == 1) {
      int k = i;
      do {
        edges[t][0] = k;
        edges[t][1] = xr[k];
        t++;
        deg[k] -= 1;
        xr[xr[k]] ^= k;
        deg[xr[k]] -= 1;
        k = xr[k];
      } while (deg[k] == 1);
    }
  }
  printf("%d\n", t);
  for (int i = 0; i < t; i++) printf("%d %d\n", edges[i][0], edges[i][1]);
  return 0;
}
