#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn], b[maxn];
int ans[maxn][2];
queue<int> q;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (long long i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
      if (a[i] == 1) q.push(i);
    }
    int tt = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      if (a[x] == 0) continue;
      int y = b[x];
      ans[tt][0] = x;
      ans[tt++][1] = y;
      b[x] ^= y;
      b[y] ^= x;
      a[x]--;
      a[y]--;
      if (a[y] == 1) q.push(y);
    }
    printf("%d\n", tt);
    for (long long i = 0; i < tt; i++)
      cout << ans[i][0] << " " << ans[i][1] << endl;
  }
  return 0;
}
