#include <bits/stdc++.h>
using namespace std;
int degree[70000 + 10], sum[70000 + 10];
int main() {
  int n, ans = 0;
  queue<int> q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &degree[i], &sum[i]);
    if (degree[i] == 1) {
      q.push(i);
    }
    ans += degree[i];
  }
  printf("%d\n", ans >> 1);
  while (!q.empty()) {
    int x1, x2;
    x1 = q.front();
    q.pop();
    if (degree[x1] == 0) continue;
    x2 = sum[x1];
    degree[x1]--;
    degree[x2]--;
    sum[x2] = sum[x2] ^ x1;
    if (degree[x2] == 1) q.push(x2);
    printf("%d %d\n", x1, x2);
  }
  return 0;
}
