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