#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 70000;
queue<int> que;
int degree[MAXN], sum[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, t, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> sum[i];
    cnt += degree[i];
    if (degree[i] == 1) que.push(i);
  }
  cout << cnt / 2 << endl;
  while (!que.empty()) {
    t = que.front();
    que.pop();
    if (degree[t] == 0) continue;
    degree[t]--;
    degree[sum[t]]--;
    sum[sum[t]] ^= t;
    if (degree[sum[t]] == 1) que.push(sum[t]);
    cout << t << ' ' << sum[t] << endl;
  }
  return 0;
}
