#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int md = 1e9 + 7;
const int N = 1e7 + 5;
struct pi {
  int first, second;
};
bool operator<(pi n1, pi n2) {
  if (n1.first == n2.first) return n1.second < n2.second;
  return n1.first > n2.first;
}
int n, v[N], s[N];
priority_queue<pi> q;
int main() {
  int sum = 0;
  pi pai;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i] >> s[i];
    sum += v[i];
    q.push((pi){v[i], i});
  }
  cout << sum / 2 << endl;
  while (!q.empty()) {
    pai = q.top();
    q.pop();
    if (!v[pai.second])
      continue;
    else {
      cout << pai.second << " " << s[pai.second] << endl;
      s[s[pai.second]] ^= pai.second;
      v[s[pai.second]]--;
      q.push((pi){v[s[pai.second]], s[pai.second]});
      v[pai.second]--;
      s[pai.second] = 0;
    }
  }
  return 0;
}
