#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<pair<int, int> > h;
  vector<int> d(n), s(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i]) {
      h.insert({d[i], i});
    }
  }
  vector<pair<int, int> > ans;
  while (!h.empty()) {
    pair<int, int> v = *h.begin();
    h.erase(h.begin());
    int w = s[v.second];
    h.erase(make_pair(d[w], w));
    d[w]--;
    s[w] ^= v.second;
    ans.push_back({v.second, w});
    if (d[w]) h.insert(make_pair(d[w], w));
  }
  cout << ans.size() << "\n";
  for (auto& x : ans) {
    cout << x.first << " " << x.second << "\n";
  }
  return 0;
}
