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