#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 17);
struct PAIR {
  int f, to;
} p[MAXN];
int np = 0;
int d[MAXN], sum[MAXN], q[MAXN], l, r;
bool use[MAXN];
int n;
void addedge(int f, int to) {
  p[np].f = f;
  p[np].to = to;
  np++;
}
void any() {
  l = r = 0;
  for (int i = 0; i < n; i++)
    if (d[i] == 1) q[r++] = i;
  while (r - l) {
    int cur = q[l++], to;
    if (!d[cur]) continue;
    addedge(cur, to = sum[cur]);
    d[to]--;
    sum[to] ^= cur;
    if (d[to] == 1) q[r++] = to;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", d + i, sum + i);
  any();
  printf("%d\n", np);
  for (int i = 0; i < np; i++) printf("%d %d\n", p[i].f, p[i].to);
  return 0;
}
