#include <bits/stdc++.h>
using namespace std;
struct Data {
  int idx, deg, xSum;
};
bool processed[65540];
Data D[65540];
void solve(int n) {
  int d = 0;
  Data data;
  queue<Data> q;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &D[i].deg, &D[i].xSum), D[i].idx = i;
    if (D[i].deg == 1) q.push(D[i]);
    d += D[i].deg;
  }
  printf("%d\n", d / 2);
  while (!q.empty()) {
    data = q.front(), q.pop();
    if (!processed[data.idx]) {
      printf("%d %d\n", data.idx, data.xSum);
      D[data.xSum].deg--, D[data.xSum].xSum ^= data.idx;
      processed[data.idx] = true;
      if (!D[data.xSum].deg)
        processed[data.xSum] = true;
      else if (D[data.xSum].deg == 1)
        q.push(D[data.xSum]);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  solve(n);
  return 0;
}
