#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long isPowerof2(long long x) { return (x && !(x & x - 1)); }
struct node {
  long long id;
  long long degree;
  long long xorsum;
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  node a[n];
  queue<node> q;
  for (long long(i) = (0); i < (n); i++) {
    a[i].id = i;
    cin >> a[i].degree;
    cin >> a[i].xorsum;
    if (a[i].degree == 1) {
      q.push(a[i]);
    }
  }
  set<pair<long long, long long> > ans;
  while (!q.empty()) {
    node tp = q.front();
    q.pop();
    ans.insert(make_pair(min(tp.id, tp.xorsum), max(tp.id, tp.xorsum)));
    a[tp.xorsum].degree--;
    a[tp.xorsum].xorsum ^= tp.id;
    if (a[tp.xorsum].degree == 1) {
      q.push(a[tp.xorsum]);
    }
  }
  cout << ans.size() << '\n';
  for (auto el : ans) {
    cout << el.first << " " << el.second << '\n';
  }
  return 0;
}
