#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int a[MAXN], deg[MAXN];
set<pair<int, int> > s;
int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> a[i];
    if (deg[i]) s.insert(make_pair(deg[i], i));
    sum += deg[i];
  }
  cout << sum / 2 << endl;
  while (s.size()) {
    pair<int, int> x = *s.begin();
    s.erase(x);
    int t = a[x.second];
    cout << x.second << ' ' << t << endl;
    s.erase(make_pair(deg[t], t));
    deg[t]--;
    a[t] ^= x.second;
    if (deg[t]) s.insert(make_pair(deg[t], t));
  }
  return 0;
}
