#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> Deg(n, 0);
  vector<unsigned> Sum(n, 0);
  queue<int> Leaves;
  for (int i = 0; i < n; i++) {
    cin >> Deg[i] >> Sum[i];
    if (Deg[i] == 1) {
      Leaves.push(i);
    }
  }
  queue<pair<int, int> > R;
  while (!Leaves.empty()) {
    int u = Leaves.front();
    Leaves.pop();
    if (Deg[u] < 1) continue;
    int v = Sum[u];
    R.push(make_pair(u, v));
    Sum[v] ^= u;
    Deg[v]--;
    if (Deg[v] == 1) Leaves.push(v);
  }
  cout << R.size() << endl;
  while (!R.empty()) {
    cout << R.front().first << " " << R.front().second << endl;
    R.pop();
  }
  return 0;
}
