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