#include <bits/stdc++.h>
using namespace std;
queue<int> q;
vector<int> Y, X;
int main() {
  int n;
  cin >> n;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    m += a;
    X.push_back(a);
    Y.push_back(b);
    if (a == 1) q.push(i);
  }
  cout << m / 2 << endl;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    if (X[i] == 0) continue;
    X[Y[i]]--;
    Y[Y[i]] ^= i;
    cout << i << " " << Y[i] << endl;
    if (X[Y[i]] == 1) q.push(Y[i]);
  }
  return 0;
}
