#include <bits/stdc++.h>
using namespace std;
int degree[(1 << 16)], s[(1 << 16)];
int main() {
  int n;
  scanf("%d", &n);
  stack<int> st;
  int total = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &degree[i], &s[i]);
    if (degree[i] == 1) st.push(i);
    total += degree[i];
  }
  printf("%d\n", total / 2);
  while (st.size() > 0) {
    int v = st.top();
    st.pop();
    if (degree[v] == 0) continue;
    int u = s[v];
    printf("%d %d\n", v, u);
    degree[u]--;
    s[u] ^= v;
    if (degree[u] == 1) st.push(u);
  }
}
