#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> vet1(n);
  vector<long long> vet2(n);
  queue<long long> fila;
  for (int i = 0; i < n; ++i) {
    cin >> vet1[i] >> vet2[i];
    if (vet1[i] == 1) {
      fila.push(i);
    }
  }
  set<pair<long long, long long> > res;
  vector<long long> foi(n);
  while (!fila.empty()) {
    auto a = fila.front();
    fila.pop();
    if (vet1[a] == 0) {
      continue;
    }
    vet1[a] -= 1;
    vet1[vet2[a]] -= 1;
    vet2[vet2[a]] ^= a;
    res.insert({min(vet2[a], a), max(vet2[a], a)});
    if (vet1[vet2[a]] == 1) {
      fila.push(vet2[a]);
    }
  }
  cout << res.size() << endl;
  for (auto& p : res) {
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}
