#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, i, j, k;
  cin >> n;
  vector<long long> d(n), s(n);
  queue<long long> q;
  for (i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) q.push(i);
  }
  set<pair<long long, long long>> ans;
  vector<bool> used(n, false);
  while (!q.empty()) {
    long long id = q.front();
    q.pop();
    if (!used[id] && (d[id] == 1)) {
      ans.insert({min(id, s[id]), max(id, s[id])});
      used[id] = true;
      d[id]--;
      d[s[id]]--;
      s[s[id]] ^= id;
      if ((d[s[id]] == 1) && (!used[s[id]])) q.push(s[id]);
    }
  }
  cout << ans.size() << "\n";
  for (auto p : ans) cout << p.first << " " << p.second << "\n";
  return 0;
}
