#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 18);
int in[N];
int x[N];
int q[N];
bool vis[N];
int t, h;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &in[i], &x[i]);
  }
  for (int i = 0; i < n; i++)
    if (in[i] == 1) q[t++] = i, vis[i] = 1;
  while (t > h) {
    int u = q[h++];
    if (vis[u] == 0) continue;
    in[x[u]]--;
    if (in[x[u]] == 1)
      q[t++] = x[u], vis[x[u]] = 1;
    else if (in[x[u]] == 0)
      vis[x[u]] = 0;
    x[x[u]] ^= u;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (vis[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 0; i < t; i++) {
    int u = q[i];
    if (vis[u]) printf("%d %d\n", u, x[u]);
  }
  return 0;
}
