#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16;
int k, n, m, d[N], a[N];
int q[N], l, r;
int u[N], v[N], num;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &a[i]);
    if (d[i] == 1) q[++r] = i;
  }
  while (++l <= r) {
    if (!d[q[l]]) continue;
    u[++num] = q[l];
    v[num] = a[q[l]];
    if (--d[v[num]] == 1) q[++r] = v[num];
    a[v[num]] ^= q[l];
  }
  cout << num << endl;
  for (int i = 1; i <= num; i++) printf("%d %d\n", u[i], v[i]);
  return 0;
}
