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