#include <bits/stdc++.h>
using namespace std;
struct node {
  int degree, s;
} ant[100000];
queue<int> q;
int vis[100000][2];
int vit[100000];
int main() {
  int n;
  memset(vit, 0, sizeof(vit));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &ant[i].degree, &ant[i].s);
    if (ant[i].degree == 1) {
      q.push(i);
    }
  }
  int sum = 0;
  while (!q.empty()) {
    int temp = q.front();
    q.pop();
    if (vit[temp] == 1) continue;
    vit[temp] = 1;
    vis[sum][0] = temp;
    vis[sum++][1] = ant[temp].s;
    ant[ant[temp].s].degree--;
    ant[ant[temp].s].s = ant[ant[temp].s].s ^ temp;
    if (ant[ant[temp].s].degree == 0) vit[ant[temp].s] = 1;
    if (ant[ant[temp].s].degree == 1) {
      q.push(ant[temp].s);
    }
  }
  printf("%d\n", sum);
  for (int i = 0; i < sum; ++i) printf("%d %d\n", vis[i][0], vis[i][1]);
  return 0;
}
