#include <bits/stdc++.h>
using namespace std;
int E[(1 << 16) + 10], X[(1 << 16) + 10];
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  set<tuple<int, int, int> > p;
  int s = 0;
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%d%d", E + i, X + i);
    p.insert(make_tuple(E[i], i, X[i]));
    s += E[i];
  }
  int c = 0;
  printf("%d\n", s / 2);
  while (p.size()) {
    auto f = *p.begin();
    p.erase(p.begin());
    int u = get<1>(f), v = get<2>(f), e = get<0>(f);
    if (!e) continue;
    printf("%d %d\n", u, v);
    auto g = p.find(make_tuple(E[v], v, X[v]));
    p.erase(g);
    --E[v], X[v] ^= u;
    if (E[v] > 0) p.insert(make_tuple(E[v], v, X[v]));
  }
  return 0;
}
