#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int deg[100100], xorsum[100100];
  vector<int> ones;
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> deg[i] >> xorsum[i];
    if (deg[i] == 1) ones.push_back(i);
  }
  set<pair<int, int> > adj;
  while (ones.size() != 0) {
    int ind = ones[ones.size() - 1];
    ones.pop_back();
    if (deg[ind] == 0) continue;
    deg[xorsum[ind]]--;
    xorsum[xorsum[ind]] ^= ind;
    adj.insert(pair<int, int>(min(ind, xorsum[ind]), max(ind, xorsum[ind])));
    if (deg[xorsum[ind]] == 1) {
      ones.push_back(xorsum[ind]);
    }
  }
  cout << adj.size() << endl;
  for (set<pair<int, int> >::iterator i = adj.begin(); i != adj.end(); ++i)
    cout << (*i).first << ' ' << (*i).second << endl;
  return 0;
}
