#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > Arr(n);
  vector<int> ProcOrd;
  for (int i = 0; i < n; i++) {
    cin >> Arr[i].first >> Arr[i].second;
    if (Arr[i].first == 1) ProcOrd.push_back(i);
  }
  vector<int> CorEd(n, 0);
  vector<pair<int, int> > Ans;
  for (int i = 0; i < ProcOrd.size(); i++) {
    int v = ProcOrd[i];
    if (CorEd[v] < Arr[v].first) {
      int u = Arr[v].second;
      CorEd[u]++;
      CorEd[v]++;
      if (Arr[u].first - CorEd[u] == 1) ProcOrd.push_back(u);
      Arr[u].second ^= v;
      Ans.push_back(make_pair(u, v));
    }
  }
  cout << Ans.size() << endl;
  for (int i = 0; i < Ans.size(); i++) {
    cout << Ans[i].first << ' ' << Ans[i].second << endl;
  }
}
