#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 16) + 1e3;
struct node {
  int degree;
  int si;
  node() {}
  node(int _degree, int _si) : degree(_degree), si(_si) {}
} nd[N];
struct edge {
  int u, v;
  edge() {}
  edge(int _u, int _v) : u(_u), v(_v) {}
} edges[N];
int cnt;
int n;
queue<int> que;
int main() {
  scanf("%d", &n);
  while (!que.empty()) que.pop();
  for (int i = 0; i < n; i++) {
    int d, s;
    scanf("%d %d", &d, &s);
    nd[i] = node(d, s);
    if (d == 1) que.push(i);
  }
  cnt = 0;
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    if (nd[p].degree == 0) continue;
    int u = nd[p].si, v = p;
    edges[cnt++] = edge(u, v);
    nd[u].si ^= p;
    nd[u].degree--;
    if (nd[u].degree == 1) que.push(u);
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) {
    printf("%d %d\n", edges[i].u, edges[i].v);
  }
  return 0;
}
