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