#include <bits/stdc++.h>
using namespace std;
int N, deg[100010], s[100010], K, ans[100010][2];
set<int> st;
int main() {
  cin >> N;
  int i;
  for (i = 0; i < N; i++) {
    cin >> deg[i] >> s[i];
    if (deg[i] == 1) st.insert(i);
  }
  int nod;
  while (st.size() != 0) {
    nod = *st.begin();
    st.erase(st.begin());
    if (deg[nod] == 0) continue;
    ans[++K][0] = nod, ans[K][1] = s[nod];
    s[s[nod]] ^= nod;
    deg[s[nod]]--;
    if (deg[s[nod]] == 1) st.insert(s[nod]);
  }
  cout << K << "\n";
  for (i = 1; i <= K; i++) cout << ans[i][0] << " " << ans[i][1] << "\n";
  return 0;
}
