#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  set<pair<int, int> > ans;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(pair<int, int>(x, y));
  }
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j <= n - 1 && v[j].first == 1) {
      if (j != v[j].second) {
        ans.insert(pair<int, int>(j, v[j].second));
        v[j].first--;
      }
      if (v[j].second <= n - 1) {
        v[v[j].second].first--;
        v[v[j].second].second ^= j;
        j = v[j].second;
      }
    }
  }
  cout << ans.size() << endl;
  for (set<pair<int, int> >::iterator it = ans.begin(); it != ans.end(); it++) {
    cout << it->first << " " << it->second << endl;
  }
  return 0;
}
