#include <bits/stdc++.h>
using namespace std;
int deg[100000], x[100000];
map<pair<int, int>, int> m;
vector<pair<int, int> > v;
int main() {
  int n, k;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &deg[i], &x[i]);
    if (deg[i] > 0) {
      pair<int, int> a;
      a.first = deg[i];
      a.second = i;
      m[a] = i;
    }
  }
  while (!m.empty()) {
    pair<pair<int, int>, int> b = *(m.begin());
    m.erase(m.begin());
    int neighbor = x[b.first.second];
    v.push_back(pair<int, int>(b.first.second, neighbor));
    map<pair<int, int>, int>::iterator it =
        m.find(pair<int, int>(deg[neighbor], neighbor));
    pair<int, int> c = it->first;
    m.erase(it);
    deg[neighbor]--;
    x[neighbor] ^= b.first.second;
    if (deg[neighbor] > 0) {
      c.first--;
      m[c] = neighbor;
    }
  }
  k = v.size();
  printf("%d\n", v.size());
  for (int i = 0; i < k; i++) {
    printf("%d %d\n", v[i]);
  }
  return 0;
}
