#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 17);
int n, d[maxn], s[maxn], st[maxn];
int outa[maxn], outb[maxn];
int main() {
  scanf("%d\n", &n);
  int top = 0;
  for (int i = (0); i <= (n - 1); i++) {
    scanf("%d%d\n", &d[i], &s[i]);
    if (d[i] == 1) st[++top] = i;
  }
  int tot = 0;
  while (top > 0) {
    int x = st[top--];
    if (d[x] == 0) continue;
    tot++;
    outa[tot] = s[x];
    outb[tot] = x;
    if (--d[s[x]] == 1) st[++top] = s[x];
    s[s[x]] ^= x;
  }
  printf("%d\n", tot);
  for (int i = (1); i <= (tot); i++) printf("%d %d\n", outa[i], outb[i]);
  return 0;
}
