#include <bits/stdc++.h>
using namespace std;
struct vec {
  int degree, num;
} v[500000];
struct edge {
  int u, v;
} edg[500000];
int no;
int main() {
  int n, i, j;
  queue<int> q;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &v[i].degree, &v[i].num);
    if (v[i].degree == 1) q.push(i);
  }
  while (!q.empty()) {
    int tmp = q.front(), e;
    q.pop();
    if (v[tmp].degree < 1) continue;
    e = v[tmp].num ^ 0;
    v[e].degree--;
    v[e].num ^= tmp;
    edg[no].u = tmp;
    edg[no++].v = e;
    if (v[e].degree == 1) q.push(e);
  }
  printf("%d\n", no);
  for (i = 0; i < no; i++) printf("%d %d\n", edg[i].u, edg[i].v);
  return 0;
}
