#include <bits/stdc++.h>
using namespace std;
struct V {
  int d;
  int s;
};
struct E {
  int v1;
  int v2;
};
V v[65536];
vector<E> ve;
queue<int> qv;
int main() {
  int n;
  while (cin >> n) {
    ve.clear();
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &v[i].d, &v[i].s);
      if (v[i].d == 1) qv.push(i);
    }
    while (!qv.empty()) {
      int t = qv.front();
      qv.pop();
      if (!v[t].d) continue;
      v[t].d--;
      int u = v[t].s;
      v[u].d--;
      v[u].s ^= t;
      if (v[u].d == 1) qv.push(u);
      ve.push_back((E){u, t});
    }
    cout << ve.size() << endl;
    for (int i = 0; i < ve.size(); i++)
      cout << ve[i].v2 << " " << ve[i].v1 << endl;
  }
  return 0;
}
