#include <bits/stdc++.h>
using namespace std;
bool visited[100005];
int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  int f = 0, bc = 1;
  int x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1 && !visited[i] && !visited[b[i]]) {
      f++;
      x[f] = i;
      visited[i] = true;
      y[f] = b[i];
    }
  }
  while (f > bc) {
    int g = x[bc];
    int h = y[bc];
    b[h] = (b[h] ^ g);
    a[h]--;
    if (a[h] == 1 && !visited[h] && !visited[b[h]]) {
      f++;
      x[f] = h;
      y[f] = b[h];
      visited[h] = true;
    }
    bc++;
  }
  cout << f << "\n";
  for (int i = 1; i <= f; i++) {
    cout << x[i] << " " << y[i] << "\n";
  }
}
