#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int res, ok = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') ok = -1;
  res = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    res = res * 10 + ch - '0';
  return res * ok;
}
queue<int> q;
struct point {
  int dgree, s;
} a[100005];
struct edge {
  int u, v;
} b[100005];
int n, num;
int main() {
  n = read();
  for (int i = 0; i < n; i++) {
    a[i].dgree = read();
    a[i].s = read();
    if (a[i].dgree == 1) q.push(i);
  }
  while (!q.empty()) {
    int now = q.front(), v;
    q.pop();
    if (a[now].dgree == 0) continue;
    v = a[now].s;
    a[v].dgree--;
    a[v].s ^= now;
    num++;
    b[num].u = now;
    b[num].v = v;
    if (a[v].dgree == 1) q.push(v);
  }
  printf("%d\n", num);
  for (int i = 1; i <= num; i++) printf("%d %d\n", b[i].u, b[i].v);
  return 0;
}
