#include <bits/stdc++.h>
using namespace std;
const int INF = 0xfffff;
const int M = 1 << 17;
int d[M], s[M], res[M];
int main() {
  int n, to, t, sum;
  cin >> n;
  to = t = sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", d + i, s + i);
    sum += d[i];
    if (d[i] == 1) res[++to] = i;
  }
  printf("%d\n", sum / 2);
  while (t < to) {
    int u = res[++t];
    if (d[u] == 0) continue;
    printf("%d %d\n", u, s[u]);
    d[s[u]]--;
    s[s[u]] ^= u;
    if (d[s[u]] == 1) res[++to] = s[u];
  }
  return 0;
}
