#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 16) + 5;
int degree[maxn], XOR_sum[maxn];
int main() {
  int n;
  cin >> n;
  queue<int> q;
  pair<int, int> ans[maxn];
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &degree[i], &XOR_sum[i]);
    if (degree[i] == 1) q.push(i);
  }
  int cnt = 0;
  while (!q.empty()) {
    int from = q.front();
    q.pop();
    if (degree[from] == 1) {
      int to = XOR_sum[from];
      ans[cnt].first = from;
      ans[cnt++].second = to;
      degree[to]--;
      XOR_sum[to] ^= from;
      if (degree[to] == 1) q.push(to);
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
