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