#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 17;
int du[maxN], s[maxN];
int n;
int an[maxN][2], sz;
void slv() {
  sz = 0;
  queue<int> que;
  for (int i = 0; i < n; i++)
    if (du[i] == 1) que.push(i);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (!du[u]) continue;
    int v = s[u];
    du[u]--, du[v]--;
    an[sz][0] = u, an[sz][1] = v, sz++;
    s[v] ^= u;
    if (du[v] == 1) que.push(v);
  }
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) printf("%d %d\n", an[i][0], an[i][1]);
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%d%d", &du[i], &s[i]);
    slv();
  }
  return 0;
}
