#include <bits/stdc++.h>
using namespace std;
int n;
int d[100005];
int x[100005];
vector<int> v;
int m = 0;
vector<pair<int, int> > edge;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &x[i]);
    if (d[i] == 1) v.push_back(i);
  }
  while (!v.empty()) {
    int u = v[v.size() - 1];
    v.pop_back();
    if (d[u] != 0) {
      edge.push_back(make_pair(max(u, x[u]), min(u, x[u])));
      x[x[u]] ^= u;
      d[x[u]]--;
      if (d[x[u]] == 1) v.push_back(x[u]);
    }
  }
  printf("%d\n", edge.size());
  for (int i = 0; i < edge.size(); i++)
    printf("%d %d\n", edge[i].first, edge[i].second);
  return 0;
}
