#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
struct node {
  int id;
};
node a, b, c;
int xr[N], d[N];
int mark[N];
int vis[N];
vector<int> mp[N];
set<pair<int, int> > st;
int main() {
  int n, s, m = 0, k = 0;
  queue<node> q;
  ;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &xr[i]);
    m += d[i];
    a.id = i;
    if (d[i] == 1) {
      q.push(a);
    }
  }
  while (q.size()) {
    b = q.front();
    q.pop();
    int id = b.id;
    int bd = d[xr[id]];
    d[id]--;
    d[xr[id]]--;
    if (d[id] < 0) continue;
    if (d[xr[id]] == 1) {
      c.id = xr[id];
      q.push(c);
    }
    xr[xr[id]] ^= id;
    int xa = id;
    int xb = xr[id];
    if (xb < xa) swap(xa, xb);
    st.insert(make_pair(xa, xb));
  }
  cout << m / 2 << endl;
  set<pair<int, int> >::iterator it;
  for (it = st.begin(); it != st.end(); it++) {
    printf("%d %d\n", it->first, it->second);
  }
  return 0;
}
