#include <bits/stdc++.h>
using namespace std;
int n, m, i, now, d[100001], s[100001], x[100001], y[100001];
queue<int> q;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &s[i]);
    if (d[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    now = q.front();
    q.pop();
    if (d[now] == 1) {
      s[s[now]] ^= now;
      m++;
      x[m] = now;
      y[m] = s[now];
      if ((--d[s[now]]) == 1) q.push(s[now]);
    }
  }
  printf("%d\n", m);
  for (i = 1; i <= m; i++) printf("%d %d\n", x[i], y[i]);
  return 0;
}
