#include <bits/stdc++.h>
int vis[1000005], top = 0, bottom = 0;
struct d {
  int sum, deg;
} stuff[100005];
int main() {
  int i, j, k, m, n, x, y, z, ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &stuff[i].deg, &stuff[i].sum);
    if (stuff[i].deg == 1) vis[bottom++] = i;
    ans += stuff[i].deg;
  }
  printf("%d\n", ans / 2);
  while (top < bottom) {
    if (stuff[vis[top]].deg != 1) {
      top++;
      continue;
    }
    printf("%d %d\n", vis[top], stuff[vis[top]].sum);
    stuff[stuff[vis[top]].sum].sum = stuff[stuff[vis[top]].sum].sum ^ vis[top];
    stuff[stuff[vis[top]].sum].deg--;
    if (stuff[stuff[vis[top]].sum].deg == 1)
      vis[bottom++] = stuff[vis[top]].sum;
    top++;
  }
  return 0;
}
