#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int degree[n], xorsum[n];
  queue<int> Q;
  int used = 0;
  for (int i = 0; i < n; ++i) {
    cin >> degree[i] >> xorsum[i];
    if (degree[i] == 1) Q.push(i);
    if (degree[i] == 0) {
      if (xorsum[i] != 0) assert(false);
      used++;
    }
  }
  vector<pair<int, int> > ans;
  while (!Q.empty()) {
    int from = Q.front();
    Q.pop();
    used++;
    if (degree[from] == 0) {
      if (xorsum[from] != 0) assert(false);
      continue;
    }
    degree[from]--;
    int to = xorsum[from];
    xorsum[from] = 0;
    if (to >= n) assert(false);
    ans.push_back(make_pair(from, to));
    xorsum[to] ^= from;
    if (degree[to] == 0) assert(false);
    degree[to]--;
    if (degree[to] == 1) Q.push(to);
  }
  if (used != n) assert(false);
  cout << ans.size() << endl;
  for (size_t i = 0; i < ans.size(); ++i)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
