#include <bits/stdc++.h>
using namespace std;
struct node {
  int from, to;
} t[110000];
int ans[110000], degree[110000];
int main() {
  int n, m, i, j, k, l, a, b;
  while (scanf("%d", &n) != EOF) {
    k = 0;
    queue<int> q;
    for (i = 0; i < n; i++) {
      scanf("%d%d", &degree[i], &ans[i]);
      if (degree[i] == 1) q.push(i);
    }
    k = 0;
    while (!q.empty()) {
      n = q.front();
      q.pop();
      if (degree[n] == 1) {
        m = ans[n];
        t[k].from = n;
        t[k++].to = m;
        degree[m]--;
        ans[m] ^= n;
        if (degree[m] == 1) q.push(m);
      }
    }
    printf("%d\n", k);
    for (i = 0; i < k; i++) printf("%d %d\n", t[i].from, t[i].to);
  }
  return 0;
}
