#include <bits/stdc++.h>
using namespace std;
struct nodo {
  int deg, sum, indice;
  bool operator<(const nodo& oth) const {
    if (deg != oth.deg)
      return deg < oth.deg;
    else if (sum != oth.sum)
      return sum < oth.sum;
    else
      return indice < oth.indice;
  }
};
int N;
nodo v[100010];
set<nodo> insieme;
vector<pair<int, int> > archi;
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> v[i].deg >> v[i].sum;
    v[i].indice = i;
    if (v[i].deg > 0) insieme.insert(v[i]);
  }
  while (!insieme.empty()) {
    set<nodo>::iterator i = insieme.begin();
    insieme.erase(insieme.find(v[i->sum]));
    v[i->sum].deg--;
    v[i->sum].sum ^= i->indice;
    archi.push_back({i->indice, i->sum});
    if (v[i->sum].deg > 0) insieme.insert(v[i->sum]);
    insieme.erase(i);
  }
  cout << (int)archi.size() << endl;
  for (auto i : archi) cout << i.first << " " << i.second << endl;
  return 0;
}
