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