#include <bits/stdc++.h>
using namespace std;
int main() {
  long long numb;
  cin >> numb;
  pair<int, int> pa;
  vector<pair<int, int>> answer;
  queue<int> q;
  long long* S = new long long[numb];
  long long* D = new long long[numb];
  bool* used = new bool[numb];
  for (int i = 0; i < numb; i++) {
    cin >> D[i] >> S[i];
    used[i] = false;
    if (D[i] == 1) {
      q.push(i);
    }
  }
  vector<int> ver;
  int next;
  while (!q.empty()) {
    int index = q.front();
    q.pop();
    if (!used[index] && D[index] == 1) {
      next = S[index];
      if (!used[next]) {
        answer.push_back(make_pair(index, S[index]));
        D[next]--;
        S[next] = S[next] ^ index;
        if (D[next] == 1) {
          q.push(next);
        }
        D[index]--;
        used[index] = true;
      }
    }
  }
  cout << answer.size() << endl;
  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i].first << " " << answer[i].second << endl;
  }
  return 0;
}
