#include <bits/stdc++.h>
using namespace std;
long n, dsum = 0, i, k = 0, t;
long a[65537][2];
long tree[65537][2];
int form(int i) {
  tree[k][0] = i;
  tree[k][1] = a[i][1];
  a[i][0]--;
  a[a[i][1]][0]--;
  a[a[i][1]][1] ^= i;
  k++;
  t = a[i][1];
  a[i][1] = 0;
  if (a[t][0] == 1) form(t);
  return 0;
}
int main() {
  cin >> n;
  int flag = 0;
  for (int j = 0; j < n; j++) {
    cin >> a[j][0] >> a[j][1];
  }
  for (int j = 0; j < n; j++) {
    if (a[j][0] == 1) form(j);
  }
  cout << k << endl;
  for (i = 0; i < k; i++) cout << tree[i][0] << " " << tree[i][1] << endl;
}
