#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, w, e, r, t = 0, y = 0, c, a[66000], s[66000], d[66000], f[66000],
                  g[66000];
  cin >> q;
  for (w = 0; w < q; w++) {
    scanf("%d%d", &a[w], &s[w]);
    if (a[w] == 1) {
      d[t] = w;
      t++;
    }
  }
  for (e = 0, r = t; e < r; r = t)
    for (; e < r; e++)
      if (a[d[e]] == 1) {
        c = d[e];
        f[y] = c;
        g[y] = s[c];
        y++;
        a[s[c]]--;
        s[s[c]] ^= c;
        if (a[s[c]] == 1) {
          d[t] = s[c];
          t++;
        }
      }
  cout << y;
  for (w = 0; w < y; w++) printf("\n%d %d", f[w], g[w]);
  return 0;
}
