#include <bits/stdc++.h>
using namespace std;
const int MAX = (1 << 16) + 5;
pair<pair<int, int>, int> node[MAX];
pair<int, int> v[MAX];
int main() {
  int n;
  cin >> n;
  set<pair<pair<int, int>, int> > s;
  for (int i = (0); i < (n); i++) {
    cin >> v[i].first >> v[i].second;
    s.insert(make_pair(v[i], i));
  }
  vector<pair<int, int> > edges;
  while (s.size() > 1) {
    pair<pair<int, int>, int> x = *(s.begin());
    if (x.first.first == 0) {
      s.erase(x);
      continue;
    }
    int cur = x.first.second;
    edges.push_back(make_pair(x.second, cur));
    pair<pair<int, int>, int> p = make_pair(v[cur], cur);
    s.erase(x);
    s.erase(p);
    v[cur].first--, v[cur].second ^= x.second;
    s.insert(make_pair(v[cur], cur));
  }
  cout << edges.size() << endl;
  for (int i = (0); i < (edges.size()); i++) {
    cout << edges[i].first << " " << edges[i].second << endl;
  }
  return 0;
}
