#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int degree[70000];
  int xsum[70000];
  int res[70000][2];
  int k = 0;
  cin >> n;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> xsum[i];
    if (degree[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int front = q.front();
    q.pop();
    if (degree[front] == 0) continue;
    res[k][0] = front;
    res[k++][1] = xsum[front];
    xsum[xsum[front]] ^= front;
    degree[xsum[front]]--;
    if (degree[xsum[front]] == 1) q.push(xsum[front]);
  }
  cout << k << endl;
  for (int i = 0; i < k; i++) {
    cout << res[i][0] << " " << res[i][1] << endl;
  }
  return 0;
}
