#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, degree, sum, current, coun;
  int XOR[1 << 17 + 1], D[1 << 17 + 1];
  scanf("%d", &n);
  set<pair<int, int> > st;
  set<pair<int, int> >::iterator it;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &degree, &sum);
    XOR[i] = sum;
    D[i] = degree;
    st.insert(make_pair(degree, i));
  }
  coun = 0;
  queue<pair<int, int> > Q;
  while (st.size() > 0) {
    it = st.begin();
    current = (*it).second;
    if ((*it).first == 1) {
      coun++;
      Q.push(make_pair(current, XOR[current]));
      st.erase(it);
      st.erase(st.find(make_pair(D[XOR[current]], XOR[current])));
      D[XOR[current]]--;
      st.insert(make_pair(D[XOR[current]], XOR[current]));
      XOR[XOR[current]] = XOR[XOR[current]] ^ current;
    } else {
      st.erase(it);
    }
  }
  pair<int, int> top;
  printf("%d\n", coun);
  while (!Q.empty()) {
    top = Q.front();
    Q.pop();
    printf("%d %d\n", top.first, top.second);
  }
  return 0;
}
