#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[n], sum[n];
  stack<int> s;
  int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> sum[i];
    x += d[i];
    if (d[i] == 1) s.push(i);
  }
  cout << x / 2 << endl;
  while (!s.empty()) {
    int t = s.top();
    s.pop();
    if (d[t] == 0) continue;
    cout << t << " " << sum[t] << endl;
    d[sum[t]]--;
    sum[sum[t]] ^= t;
    if (d[sum[t]] == 1) s.push(sum[t]);
  }
  return 0;
}
