#include <bits/stdc++.h>
using namespace std;
int n;
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
vector<pair<int, int> > v;
int sum[100005];
int bak[100005];
int main() {
  int i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    if (j > 0) st.insert(make_pair(j, i));
    sum[i] = k;
    bak[i] = j;
  }
  while (!st.empty()) {
    it = st.begin();
    j = (*it).first;
    i = (*it).second;
    v.push_back(make_pair(i, sum[i]));
    st.erase(make_pair(j, i));
    j = sum[i];
    st.erase(make_pair(bak[j], j));
    sum[i] = sum[i] ^ j;
    sum[j] = sum[j] ^ i;
    bak[j]--;
    bak[i]--;
    if (bak[j] > 0) st.insert(make_pair(bak[j], j));
  }
  cout << v.size() << "\n";
  for (i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << "\n";
  }
  return 0;
}
