#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 16) + 16;
int n;
int deg[MAXN], s[MAXN];
int sol;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &deg[i], &s[i]);
    sol += deg[i];
  }
  sol /= 2;
  printf("%d\n", sol);
  for (int i = 0; i < n; ++i) {
    int x = i;
    while (deg[x] == 1) {
      printf("%d %d\n", x, s[x]);
      int y = s[x];
      deg[y]--;
      s[y] ^= x;
      deg[x]--;
      s[x] ^= y;
      if (deg[y] == 1) x = y;
    }
  }
}
