#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
int main() {
  int t, p, i, sum = 0;
  queue<int> q;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) q.push(i);
    sum += a[i];
  }
  cout << sum / 2 << endl;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    int deg = a[p];
    if (deg == 1) {
      b[b[p]] ^= p;
      cout << p << " " << b[p] << endl;
      a[p]--;
      a[b[p]]--;
      if (a[b[p]] == 1) q.push(b[p]);
    }
  }
  return 0;
}
