#include <bits/stdc++.h>
using namespace std;
int d[65537], x[65537];
int f[65537], t[65537], c;
int main() {
  int n;
  scanf("%d", &n);
  queue<int> Q;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", d + i, x + i);
    if (d[i] == 1) Q.push(i);
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (d[u] != 1) continue;
    f[c] = u;
    t[c] = x[u];
    c++;
    d[x[u]]--;
    x[x[u]] ^= u;
    if (d[x[u]] == 1) Q.push(x[u]);
  }
  printf("%d\n", c);
  for (int i = 0; i < c; ++i) printf("%d %d\n", f[i], t[i]);
  return 0;
}
