#include <bits/stdc++.h>
using namespace std;
bool debug;
const int inf = 1e9 + 5;
const int nax = 1e6 + 5;
int first[nax], suma[nax];
struct cmp {
  bool operator()(int a, int b) {
    if (first[a] == first[b]) return a < b;
    return first[a] < first[b];
  }
};
set<int, cmp> s;
int main(int argc, char* argv[]) {
  debug = argc > 1;
  int n;
  scanf("%d", &n);
  int pomik = 0;
  for (int i = (0); i <= ((n)-1); ++i) {
    scanf("%d%d", &first[i], &suma[i]);
    pomik += first[i];
  }
  for (int i = (0); i <= ((n)-1); ++i) s.insert(i);
  printf("%d\n", pomik / 2);
  while (!s.empty()) {
    auto it = s.begin();
    int a = *it;
    s.erase(it);
    if (first[a]) {
      printf("%d %d\n", a, suma[a]);
      int b = suma[a];
      s.erase(b);
      first[b]--;
      suma[b] ^= a;
      s.insert(b);
    }
    if (debug) {
      printf("debug ");
      for (auto a : s) printf("(%d, %d, %d),  ", a, first[a], suma[a]);
    }
  }
  return 0;
}
