#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > v, vp[2];
  map<pair<int, int>, int> ans;
  int i;
  for (i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v.push_back(pair<int, int>(a, b));
    if (a == 1) vp[0].push_back(pair<int, int>(i, b));
  }
  int f = 0;
  while (vp[f].size() != 0) {
    vector<pair<int, int> >::iterator it;
    for (it = vp[f].begin(); it != vp[f].end(); ++it) {
      int d = it->first;
      int k = it->second;
      pair<int, int> s;
      if (d < k)
        s = pair<int, int>(d, k);
      else
        s = pair<int, int>(k, d);
      if (ans.find(s) == ans.end()) ans[s] = 1;
      v[k].first -= 1;
      v[k].second ^= it->first;
      if (v[k].first == 1) {
        vp[(f + 1) % 2].push_back(pair<int, int>(k, v[k].second));
      }
    }
    vp[f].clear();
    f = (f + 1) % 2;
  }
  map<pair<int, int>, int>::iterator it;
  cout << ans.size() << endl;
  for (it = ans.begin(); it != ans.end(); ++it) {
    printf("%d %d\n", (it->first).first, (it->first).second);
  }
  return 0;
}
