#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
int d[100010], s[100010], q[100010], p[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    p[i] = -1;
    scanf("%d %d", &d[i], &s[i]);
  }
  int m = 0, qs = 0, qe = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == 1) {
      q[qe++] = i;
    }
  }
  while (qs != qe) {
    int x = q[qs++];
    if (d[x] == 0) continue;
    int y = s[x];
    s[y] ^= x;
    d[y]--;
    adj[x].push_back(y);
    m++;
    if (d[y] == 1) {
      q[qe++] = y;
    }
  }
  printf("%d\n", m);
  for (int i = 0; i < n; i++) {
    for (int j : adj[i]) {
      printf("%d %d\n", i, j);
    }
  }
  return 0;
}
