#include <bits/stdc++.h>
using namespace std;
int main() {
  long long nnn;
  cin >> nnn;
  vector<pair<long long, long long> > vecc(nnn);
  queue<long long> qq;
  vector<pair<long long, long long> > anss;
  for (long long i = 0; i < nnn; i++) {
    long long i1, i2;
    cin >> i1 >> i2;
    vecc[i] = make_pair(i1, i2);
    if (i1 == 1) qq.push(i);
  }
  while (!qq.empty()) {
    long long zz = qq.front();
    qq.pop();
    if (vecc[zz].first == 0) continue;
    vecc[zz].first--;
    long long ans1 = zz;
    long long ans2 = vecc[zz].second;
    vecc[zz].second = 0;
    vecc[ans2].first--;
    vecc[ans2].second ^= zz;
    anss.push_back(make_pair(ans1, ans2));
    if (vecc[ans2].first == 1) qq.push(ans2);
  }
  long long kk = anss.size();
  cout << anss.size() << endl;
  for (long long i = 0; i < kk; i++)
    cout << anss[i].first << " " << anss[i].second << endl;
  return 0;
}
