#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
int n, deg[MAXN], s[MAXN];
std::queue<int> q;
int main() {
  scanf("%d", &n);
  int sm = 0;
  for (int i = 0; i <= n - 1; ++i) scanf("%d%d", deg + i, s + i), sm += deg[i];
  for (int i = 0; i <= n - 1; ++i)
    if (deg[i] == 1) q.push(i);
  sm >>= 1;
  printf("%d\n", sm);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (!deg[v]) continue;
    printf("%d %d\n", v, s[v]);
    s[s[v]] ^= v;
    --deg[s[v]];
    if (deg[s[v]] == 1) q.push(s[v]);
  }
  return 0;
}
