#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 1000 * 1000;
set<pair<int, int> > is;
int deg[MAXN], x[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> x[i];
    is.insert(make_pair(deg[i], i));
  }
  vector<pair<int, int> > ans;
  while (!is.empty()) {
    int v = is.begin()->second;
    is.erase(is.begin());
    if (deg[v] > 0) {
      int ne = x[v];
      ans.push_back(make_pair(v, ne));
      is.erase(is.find(make_pair(deg[ne], ne)));
      deg[ne]--;
      x[ne] ^= v;
      is.insert(make_pair(deg[ne], ne));
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
