#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long int n, i;
  cin >> n;
  long long int deg[n], xo[n];
  queue<long long int> q;
  vector<pair<long long int, long long int> > v;
  for (i = 0; i < n; i++) {
    cin >> deg[i] >> xo[i];
    if (deg[i] == 1) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    long long int k = q.front();
    q.pop();
    if (deg[k] == 0) {
      continue;
    }
    deg[k]--;
    long long int kk = xo[k];
    v.push_back({kk, k});
    xo[kk] = xo[kk] ^ k;
    deg[kk]--;
    if (deg[kk] == 1) {
      q.push(kk);
    }
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}
