#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
int const mod = 1e9 + 7;
int const INF = 1 << 29;
const int M = (1 << 16) + 5;
int d[M], s[M];
int main() {
  int n, m = 0;
  cin >> n;
  queue<int> Q;
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> s[i];
    m += d[i];
    if (d[i] == 1) {
      Q.push(i);
    }
  }
  cout << m / 2;
  putchar('\n');
  while (!Q.empty()) {
    int a = Q.front();
    Q.pop();
    if (d[a] == 0) continue;
    int b = s[a];
    cout << a << ' ' << b;
    putchar('\n');
    d[b]--;
    s[b] ^= a;
    if (d[b] == 1) Q.push(b);
  }
  return 0;
}
