#include <bits/stdc++.h>
using namespace std;
char nc() {
  static char buf[1048576], *p1 = buf, *p2 = buf;
  if (p1 == p2) {
    p1 = buf;
    p2 = buf + fread(buf, 1, 1048576, stdin);
  }
  return *p1++;
}
long long scan() {
  long long sig = 1ll, sum = 0ll;
  char f = nc();
  while ((f < '0' || f > '9') && f != '-') f = nc();
  if (f == '-') {
    sig = -1;
    f = nc();
  }
  while (f >= '0' && f <= '9') {
    sum = sum * 10ll + f - '0';
    f = nc();
  }
  sum *= sig;
  return sum;
}
long long d[70000], tmp, rst;
long long s[70000];
vector<long long> rd[70000];
long long ans[70000][2], m;
long long n;
int main() {
  n = scan();
  for (int i = 0; i < n; ++i) {
    d[i] = scan();
    if (d[i] == 1) rd[1].push_back(i);
    s[i] = scan();
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < rd[i].size(); ++j) {
      if (d[rd[i][j]] != 1) continue;
      ++m;
      ans[m][0] = rd[i][j];
      ans[m][1] = s[rd[i][j]];
      s[ans[m][1]] ^= rd[i][j];
      --d[ans[m][1]];
      --d[rd[i][j]];
      if (d[ans[m][1]] == 1) {
        rd[i + 1].push_back(ans[m][1]);
      }
    }
  }
  printf("%lld\n", m);
  for (int i = 1; i <= m; ++i) {
    printf("%lld %lld\n", ans[i][0], ans[i][1]);
  }
  return 0;
}
