#include <bits/stdc++.h>
using namespace std;
int main() {
  int nodes;
  cin >> nodes;
  int degree[nodes], xorSum[nodes];
  queue<int> q;
  for (int i = 0; i < nodes; i++) {
    cin >> degree[i] >> xorSum[i];
    if (degree[i] == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > answer;
  while (!q.empty()) {
    int from = q.front();
    q.pop();
    if (degree[from]) {
      int to = xorSum[from];
      degree[from]--;
      degree[to]--;
      answer.push_back(make_pair(from, to));
      xorSum[from] = 0;
      xorSum[to] = xorSum[to] ^ from;
      if (degree[to] == 1) q.push(to);
    }
  }
  cout << answer.size() << endl;
  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i].first << " " << answer[i].second << endl;
  }
}
