#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (1 << 17) + 5;
multiset<pair<int, int> > ms;
int n;
int degree[MAX_N], s[MAX_N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &degree[i], &s[i]);
  for (int i = 0; i < n; i++) {
    ms.insert(make_pair(degree[i], i));
  }
  int degree_sum = accumulate(degree, degree + n, 0);
  printf("%d\n", degree_sum / 2);
  while (!ms.empty()) {
    pair<int, int> a = *ms.begin();
    int u = a.second;
    int v = s[u];
    ;
    ;
    ms.erase(ms.begin());
    if (degree[u] == 0) continue;
    ;
    ms.erase(ms.lower_bound(make_pair(degree[v], v)));
    degree[v]--;
    s[v] ^= u;
    ms.insert(make_pair(degree[v], v));
    printf("%d %d\n", u, v);
  }
  return 0;
}
