#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5;
int xr[maxN];
int deg[maxN];
set<pair<int, int> > st;
int main() {
  int n;
  ios_base::sync_with_stdio(0);
  cin >> n;
  int ed = 0;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xr[i];
    st.insert(make_pair(deg[i], i));
    ed += deg[i];
  }
  ed /= 2;
  cout << ed << endl;
  while (!st.empty()) {
    pair<int, int> pp = *st.begin();
    st.erase(pp);
    if (pp.first == 0) {
      continue;
    }
    deg[pp.second]--;
    if (pp.first == 1) {
      int t = xr[pp.second];
      cout << t << " " << pp.second << "\n";
      st.erase(make_pair(deg[t], t));
      deg[t]--;
      xr[t] ^= pp.second;
      st.insert(make_pair(deg[t], t));
    }
  }
  return 0;
}
