#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000111;
priority_queue<pair<int, int> > PR;
int deg[MAXN], sxor[MAXN];
int ojc[MAXN];
int find(int v) {
  if (ojc[v] < 0) return v;
  ojc[v] = find(ojc[v]);
  return ojc[v];
}
void unia(int a, int b) {
  int aa = find(a), bb = find(b);
  if (aa != bb) {
    if (ojc[aa] > ojc[bb]) swap(aa, bb);
    ojc[aa] += ojc[bb];
    ojc[bb] = aa;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int kraw = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &deg[i], &sxor[i]);
    kraw += deg[i];
    PR.emplace(-deg[i], i);
    ojc[i] = -1;
  }
  printf("%d\n", kraw / 2);
  while (!PR.empty()) {
    int val, a;
    tie(val, a) = PR.top();
    PR.pop();
    val = -val;
    if (deg[a] != val) continue;
    if (val == 0) continue;
    if (val == 1) {
      int b = sxor[a];
      printf("%d %d\n", a, b);
      sxor[b] ^= a;
      deg[b]--;
      deg[a]--;
      sxor[a] = 0;
      PR.emplace(-deg[b], b);
    }
  }
  return 0;
}
