#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
string NumberToString(long long Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
long long StringToNumber(const string &Text) {
  stringstream ss(Text);
  long long result;
  return ss >> result ? result : 0;
}
void solve() {}
int d[66000], s[66000];
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> leafs;
  set<pair<int, int> > edges;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) {
      leafs.insert(i);
    }
    sum += d[i];
  }
  long long num = sum / 2;
  while (leafs.size() != 0) {
    int from = *leafs.begin();
    leafs.erase(from);
    d[from]--;
    int to = s[from];
    s[to] ^= from;
    d[to]--;
    int from1, to1;
    from1 = max(from, to);
    to1 = min(from, to);
    edges.insert(make_pair((from1), (to1)));
    if (d[to] == 0) {
      if (leafs.find(to) != leafs.end()) {
        leafs.erase(to);
      }
    } else if (d[to] == 1) {
      leafs.insert(to);
    }
  }
  set<pair<int, int> >::iterator it;
  cout << num << endl;
  int sz = edges.size();
  for (typeof((edges).begin()) it = (edges).begin(); it != (edges).end();
       ++it) {
    cout << (*it).first << " " << (*it).second << endl;
  }
}
