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