#include <bits/stdc++.h>
using namespace std;
struct Tree {
  int d;
  int x;
} tree[70000];
struct Res {
  int p, c;
} res[70000];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    queue<int> q;
    for (int i = 0; i < n; i++) {
      int d, x;
      scanf("%d %d", &d, &x);
      tree[i].d = d;
      tree[i].x = x;
      if (d == 1) q.push(i);
    }
    int c = 0;
    while (!q.empty()) {
      int i = q.front();
      q.pop();
      if (tree[i].d != 0) {
        int j = tree[i].x;
        res[c].c = j;
        res[c].p = i;
        c++;
        tree[j].d--;
        tree[j].x ^= i;
        if (tree[j].d == 1) q.push(j);
      }
    }
    printf("%d\n", c);
    for (int i = 0; i < c; i++) {
      printf("%d %d\n", res[i].c, res[i].p);
    }
  }
  return 0;
}
