#include <bits/stdc++.h>
using namespace std;
long deg[65536], xo[65536], v1[65536], v2[65536];
long edge;
void rec(long a) {
  v1[edge] = a;
  v2[edge] = xo[a];
  edge++;
  deg[xo[a]]--;
  deg[a]--;
  xo[xo[a]] = xo[xo[a]] ^ a;
  if (deg[xo[a]] == 1) {
    rec(xo[a]);
  }
}
int main() {
  long v;
  edge = 0;
  cin >> v;
  for (long i = 0; i < v; i++) {
    cin >> deg[i] >> xo[i];
  }
  bool dif = 1;
  while (dif) {
    dif = 0;
    for (long i = 0; i < v; i++) {
      if (deg[i] == 1) {
        rec(i);
        dif = 1;
      }
    }
  }
  cout << edge;
  for (long i = 0; i < edge; i++) {
    cout << endl << v1[i] << " " << v2[i];
  }
  return 0;
}
