#include <bits/stdc++.h>
using namespace std;
int deg[66000], sum[66000];
int n, edge;
queue<int> q;
int main() {
  ios::sync_with_stdio(0);
  edge = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> sum[i];
    edge += deg[i];
    if (deg[i] == 1) q.push(i);
  }
  cout << edge / 2 << endl;
  while (!q.empty()) {
    int leaf = q.front();
    q.pop();
    if (deg[leaf] == 0) continue;
    cout << leaf << " " << sum[leaf] << endl;
    deg[leaf]--;
    deg[sum[leaf]]--;
    sum[sum[leaf]] ^= leaf;
    if (deg[sum[leaf]] == 1) q.push(sum[leaf]);
  }
  return 0;
}
