#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int d[maxn], s[maxn], X[maxn * 10], Y[maxn * 10];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int m = 0;
    queue<int> q;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &d[i], &s[i]);
      if (d[i] == 1) q.push(i);
    }
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (d[u] == 0) continue;
      m++;
      d[u]--;
      X[m] = u;
      Y[m] = s[u];
      d[s[u]]--;
      s[s[u]] ^= u;
      if (d[s[u]] == 1) q.push(s[u]);
    }
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d %d\n", X[i], Y[i]);
  }
  return 0;
}
