#include <bits/stdc++.h>
using namespace std;
int degree[100009], sv[100009], par[100009];
queue<int> q;
vector<pair<int, int> > ans;
int main() {
  int i, j, t1, t2, t3, t4, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &degree[i], &sv[i]);
    if (degree[i] == 1) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    t1 = q.front();
    q.pop();
    if (degree[t1] == 0) {
      continue;
    }
    degree[t1]--;
    t2 = sv[t1];
    ans.push_back(make_pair(t1, t2));
    sv[t2] ^= t1;
    degree[t2]--;
    if (degree[t2] == 1) {
      q.push(t2);
    }
  }
  printf("%d\n", (int)ans.size());
  for (i = 0; i < (int)ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
