#include <bits/stdc++.h>
using namespace std;
int dg[110000], v[110000];
int tdg, n, l, r = 0;
int qp[110000];
vector<int> w[110000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &dg[i], &v[i]);
  for (int i = 0; i < n; i++) {
    tdg += dg[i];
    if (dg[i] == 1) qp[++r] = i;
  }
  for (l = 1; l <= r; l++)
    if (dg[qp[l]]) {
      w[qp[l]].push_back(v[qp[l]]);
      v[v[qp[l]]] ^= qp[l];
      dg[v[qp[l]]]--;
      if (dg[v[qp[l]]] == 1) qp[++r] = v[qp[l]];
    }
  cout << tdg / 2 << endl;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < w[i].size(); j++) printf("%d %d\n", i, w[i][j]);
}
