#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 16;
int main(int argc, char const *argv[]) {
  int n, d[MAXN], s[MAXN];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &d[i], &s[i]);
  }
  vector<pair<int, int> > v;
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (d[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int f = q.front();
    q.pop();
    if (d[f] == 0) continue;
    v.push_back(make_pair(f, s[f]));
    d[f]--;
    d[s[f]]--;
    int ano = s[f];
    s[ano] ^= f;
    if (d[ano] == 1) q.push(ano);
  }
  printf("%lu\n", v.size());
  for (int i = 0; i < v.size(); ++i) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
