#include <bits/stdc++.h>
using namespace std;
int n, deg[66000], sum[66000];
queue<int> v;
vector<pair<int, int> > vi;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &deg[i], &sum[i]);
    if (deg[i] == 1) v.push(i);
  }
  while (!v.empty()) {
    int fir = v.front();
    v.pop();
    int p = deg[fir];
    int q = sum[fir];
    int tt = q;
    if (q >= n) continue;
    if (p == 1) {
      vi.push_back(make_pair(fir, tt));
      deg[fir]--;
      sum[fir] = 0;
      deg[tt]--;
      sum[tt] ^= fir;
    }
    if (deg[tt] == 1) v.push(tt);
  }
  int ln = vi.size();
  printf("%d\n", ln);
  for (int i = 0; i < ln; i++) {
    printf("%d %d\n", vi[i].first, vi[i].second);
  }
  return 0;
}
