#include <bits/stdc++.h>
using namespace std;
int d[70000], s[70000];
set<int> S;
int main() {
  int n, sum = 0, muchii = 0;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &d[i], &s[i]);
    sum += d[i];
    if (d[i] == 1) {
      S.insert(i);
    }
  }
  muchii = sum / 2;
  int times = muchii;
  vector<pair<int, int> > v;
  v.clear();
  while (times > 0 && !S.empty()) {
    int i = (*S.begin());
    int adj = s[i];
    S.erase(S.begin());
    if (d[i] == 1) {
      v.push_back(make_pair(i, adj));
      d[adj]--;
      d[i]--;
      if (d[adj] == 1) {
        S.insert(adj);
      }
      s[adj] = (s[adj] ^ i);
      times--;
    }
  }
  if (muchii != (int)v.size()) throw exception();
  printf("%d\n", muchii);
  for (int i = 0; i < (int)v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
