#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int deg[n];
  int sum[n];
  int x = 0;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> sum[i];
    x += deg[i];
    if (deg[i] == 1) q.push(i);
  }
  cout << x / 2 << endl;
  while (q.size() != 0) {
    int temp = q.front();
    q.pop();
    if (deg[temp] == 0) continue;
    int w = sum[temp];
    cout << w << " " << temp << endl;
    deg[w]--;
    sum[w] = sum[w] ^ temp;
    if (deg[w] == 1)
      q.push(w);
    else
      continue;
  }
  return 0;
}
