#include <bits/stdc++.h>
using namespace std;
int degree[70000];
int sum[70000];
int main() {
  ios_base::sync_with_stdio(false);
  queue<int> q;
  while (!q.empty()) q.pop();
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> sum[i];
    if (degree[i] == 1) q.push(i);
    ans += degree[i];
  }
  ans = ans >> 1;
  cout << ans << endl;
  while (!q.empty()) {
    int index = q.front();
    q.pop();
    if (degree[index] == 0) continue;
    int next = sum[index];
    degree[index]--;
    degree[next]--;
    sum[next] = sum[next] ^ index;
    if (degree[next] == 1) q.push(next);
    cout << index << " " << next << endl;
  }
  return 0;
}
