#include <bits/stdc++.h>
const int maxn = (1 << 16) + 10;
int degree[maxn], xorsum[maxn];
int edge[maxn][2], cnt = 0;
int Q[maxn], head = 0, tail = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &degree[i], &xorsum[i]);
    if (degree[i] == 1) Q[tail++] = i;
  }
  while (head < tail) {
    int t = Q[head++];
    if (degree[t] == 0) continue;
    degree[t] = 0;
    int neighbor = xorsum[t];
    edge[cnt][0] = t;
    edge[cnt++][1] = neighbor;
    degree[neighbor]--;
    xorsum[neighbor] ^= t;
    if (degree[neighbor] == 1) Q[tail++] = neighbor;
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; ++i) printf("%d %d\n", edge[i][0], edge[i][1]);
  return 0;
}
