#include <bits/stdc++.h>
using namespace std;
long long xorsum[(1L << 16)];
long long deg[(1L << 16)];
int main(void) {
  long long n;
  cin >> n;
  queue<long long> q;
  long long td = 0;
  for (long long i = 0; i < n; i++) {
    cin >> deg[i] >> xorsum[i];
    if (deg[i] == 1) {
      q.push(i);
    }
    td += deg[i];
  }
  vector<pair<long long, long long> > ans;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    if (deg[u] == 0) continue;
    long long v = xorsum[u];
    xorsum[v] ^= u;
    ans.push_back(make_pair(u, v));
    deg[v]--;
    if (deg[v] == 1) q.push(v);
  }
  cout << (td / 2) << endl;
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
