#include <bits/stdc++.h>
using namespace std;
int d[(1 << 16) + 5], s[(1 << 16) + 5], u[(1 << 16) + 5], v[(1 << 16) + 5];
queue<int> q;
int cnt;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &s[i]);
    if (d[i] == 1) q.push(i);
  }
  while (q.size()) {
    int p = q.front();
    q.pop();
    if (d[p] == 0) continue;
    u[cnt] = p, v[cnt] = s[p];
    s[s[p]] ^= p, cnt++;
    if ((--d[s[p]]) == 1) q.push(s[p]);
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d %d\n", u[i], v[i]);
  return 0;
}
