#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const long long LINF = INF * 1ll * INF;
const double PI = acos(-1.0);
using namespace std;
struct Item {
  int d, s, idx;
  bool operator<(const Item& it) const { return d > it.d; }
};
int d[1 << 17];
int sum[1 << 17];
int main(void) {
  priority_queue<Item> q;
  int n;
  scanf("%d", &n);
  int m = 0;
  for (int i = 0; i < n; i++) {
    Item it;
    scanf("%d %d", &it.d, &it.s);
    it.idx = i;
    q.push(it);
    d[i] = it.d;
    sum[i] = it.s;
    m += it.d;
  }
  m >>= 1;
  printf("%d\n", m);
  while (!q.empty()) {
    Item it = q.top();
    q.pop();
    if (d[it.idx] != 1) continue;
    int u = it.idx, v = sum[it.idx];
    printf("%d %d\n", u, v);
    d[u]--;
    d[v]--;
    sum[v] ^= u;
    sum[u] ^= v;
    if (d[v]) {
      it.s = sum[v];
      it.idx = v;
      it.d = d[v];
      q.push(it);
    }
  }
  return 0;
}
