#include <bits/stdc++.h>
int queue[65540];
int ansu[65540], ansv[65540];
int deg[65540], s[65540];
int main() {
  int n;
  scanf("%d", &n);
  int front = 0, rear = 0;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &deg[i], &s[i]);
    if (deg[i] == 1) queue[rear++] = i;
  }
  while (front < rear) {
    int now = queue[front++];
    if (deg[now] == 0) continue;
    ansu[tot] = now;
    int to = s[now];
    ansv[tot] = to;
    deg[to]--;
    s[to] = s[to] ^ now;
    if (deg[to] == 1) queue[rear++] = to;
    tot++;
  }
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++) {
    printf("%d %d\n", ansu[i], ansv[i]);
  }
  return 0;
}
