#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
int q[501000], head, tail, n, d[501000], s[501000], m, ox[501000], oy[501000];
int main() {
  scanf("%d", &n);
  head = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &s[i]);
    if (d[i] == 1) q[++tail] = i;
  }
  while (head <= tail) {
    int x = q[head++];
    if (d[x] != 1) continue;
    int y = s[x];
    d[y]--, s[y] ^= x;
    if (d[y] == 1) q[++tail] = y;
    ++m, ox[m] = x, oy[m] = y;
  }
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d\n", ox[i], oy[i]);
  return 0;
}
