#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18;
int n, m;
int d[maxn], xr[maxn];
queue<int> q;
int main(int argc, char *argv[]) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> xr[i];
    m += d[i];
    if (d[i] == 1) {
      q.push(i);
    }
  }
  m /= 2;
  cout << m << endl;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (d[x] == 0) continue;
    cout << x << " " << xr[x] << endl;
    xr[xr[x]] ^= x;
    --d[x];
    --d[xr[x]];
    if (d[xr[x]] == 1) q.push(xr[x]);
  }
}
