#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b, sum = 0, i, j;
  vector<pair<long long int, long long int> > v;
  queue<long long int> q;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
    if (a == 1) q.push(i);
    sum += a;
  }
  cout << sum / 2 << endl;
  while (!q.empty()) {
    i = q.front();
    j = v[q.front()].second;
    q.pop();
    if (v[i].first == 0) continue;
    cout << i << " " << j << endl;
    v[j].first -= 1;
    v[j].second ^= i;
    if (v[j].first == 1) q.push(j);
  }
  return 0;
}
