#include <bits/stdc++.h>
using namespace std;
struct node {
  long long e, s;
};
queue<int> qu;
node V[100010];
int main() {
  int T, t, m, i, j, k;
  long long e, s, u, v;
  long long n, ans1 = 0;
  scanf("%I64d", &n);
  node A;
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d", &V[i].e, &V[i].s);
    ans1 += V[i].e;
    if (V[i].e == 1) qu.push(i);
  }
  printf("%I64d\n", ans1 / 2);
  while (!qu.empty()) {
    u = qu.front();
    qu.pop();
    v = V[u].s;
    if (V[u].e == 0 || V[v].e == 0) continue;
    printf("%I64d %I64d\n", u, v);
    V[u].s ^= v;
    V[v].s ^= u;
    V[v].e--;
    V[u].e--;
    if (V[v].e == 1) qu.push(v);
  }
}
