#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 16;
int n, cnt, d[maxn], x[maxn];
queue<int> Q;
pair<int, int> a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", d + i, x + i);
    if (d[i] == 1) Q.push(i);
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (!d[u]) continue;
    int v = x[u];
    d[u] = 0;
    a[cnt++] = make_pair(u, v);
    x[v] ^= u;
    if (--d[v] == 1) Q.push(v);
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d %d\n", a[i].first, a[i].second);
  return 0;
}
