#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 16;
int d[MAXN];
int s[MAXN];
int main() {
  vector<pair<int, int> > edges;
  queue<int> q;
  int deg_sum = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) {
      q.push(i);
    }
    deg_sum += d[i];
  }
  cout << deg_sum / 2 << endl;
  while (!q.empty()) {
    int id1 = q.front();
    int id2 = s[id1];
    q.pop();
    if (d[id1] == 0) {
      continue;
    }
    cout << id1 << " " << id2 << endl;
    --d[id2];
    s[id2] ^= id1;
    if (d[id2] == 1) {
      q.push(id2);
    }
  }
  return 0;
}
