#include <bits/stdc++.h>
using namespace std;
int deg[100100];
int xr[100100];
void Solve() {
  int i, j, k, n, m;
  queue<int> q;
  scanf("%d", &(n));
  for (i = 0; i < n; i++) {
    scanf("%d%d", &(deg[i]), &(xr[i]));
    if (deg[i] == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > res;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (deg[u] == 1) {
      res.push_back(make_pair(u, xr[u]));
      deg[u]--;
      deg[xr[u]]--;
      xr[xr[u]] ^= u;
      if (deg[xr[u]] == 1) q.push(xr[u]);
    }
  }
  printf("%d\n", res.size());
  for (i = 0; i < res.size(); i++)
    printf("%d %d\n", res[i].first, res[i].second);
}
int main() {
  Solve();
  return 0;
}
