#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[n], sv[n];
  list<int> queue;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> sv[i];
    if (d[i] == 1) queue.push_back(i);
  }
  int s;
  vector<pair<int, int> > answer;
  while (!queue.empty()) {
    s = queue.front();
    queue.pop_front();
    if (d[s] == 0) continue;
    d[sv[s]]--;
    sv[sv[s]] ^= s;
    d[s]--;
    answer.push_back(make_pair(s, sv[s]));
    if (d[sv[s]] == 1) queue.push_back(sv[s]);
  }
  cout << answer.size() << endl;
  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i].first << " " << answer[i].second << endl;
  }
  return 0;
}
