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