#include <bits/stdc++.h>
int main(void) {
  int N;
  scanf("%i", &N);
  int deg[N];
  int sum[N];
  int now[N];
  int fronta[2 * N];
  int i;
  int j = 0;
  int pocet;
  int suma = 0;
  for (i = 0; i < N; i++) {
    scanf("%i %i", &deg[i], &sum[i]);
    now[i] = 0;
    if (deg[i] == 1) {
      fronta[j] = i;
      j++;
    }
    suma = suma + deg[i];
  }
  pocet = suma / 2;
  int zrovna = 0;
  int hrany[pocet][2];
  for (i = 0; i < j; i++) {
    if (deg[fronta[i]] == 1) {
      hrany[zrovna][0] = fronta[i];
      hrany[zrovna][1] = sum[fronta[i]];
      deg[fronta[i]]--;
      deg[sum[fronta[i]]]--;
      sum[sum[fronta[i]]] = sum[sum[fronta[i]]] ^ fronta[i];
      zrovna++;
      if (deg[sum[fronta[i]]] == 1) {
        fronta[j] = sum[fronta[i]];
        j++;
      }
      sum[fronta[i]] = 0;
    }
  }
  printf("%i\n", pocet);
  for (i = 0; i < pocet; i++) {
    printf("%i %i\n", hrany[i][0], hrany[i][1]);
  }
  return 0;
}
