#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 16;
set<pair<int, pair<int, int> > >::iterator iters[MAXN];
int main() {
  vector<pair<int, int> > edges;
  set<pair<int, pair<int, int> > > vert;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int d, s;
    cin >> d >> s;
    iters[i] = vert.insert(make_pair(d, make_pair(s, i))).first;
  }
  while (!vert.empty()) {
    if (vert.begin()->first > 0) {
      int d = vert.begin()->first;
      int s = vert.begin()->second.first;
      int id = vert.begin()->second.second;
      vert.erase(vert.begin());
      edges.push_back(make_pair(id, s));
      auto it = iters[s];
      auto p = *it;
      vert.erase(it);
      p.second.first ^= id;
      --p.first;
      iters[s] = vert.insert(p).first;
    } else {
      vert.erase(vert.begin());
    }
  }
  cout << edges.size() << endl;
  for (int i = 0; i < edges.size(); ++i) {
    cout << edges[i].first << " " << edges[i].second << endl;
  }
  return 0;
}
