#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *a, *b, r = 0;
  queue<int> x;
  cin >> n;
  a = new int[n];
  b = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) x.push(i);
    r += a[i];
  }
  cout << r / 2 << '\n';
  while (!x.empty()) {
    int v = x.front();
    x.pop();
    if (a[v] == 0) continue;
    cout << v << ' ' << b[v] << '\n';
    --a[v];
    int j = b[v];
    a[j]--, b[j] ^= v;
    if (a[j] == 1) x.push(j);
  }
  return 0;
}
