#include <bits/stdc++.h>
const int N = (1 << 16) + 10;
int d[N], s[N];
int main() {
  std ::queue<int> Q;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &d[i], &s[i]);
    if (d[i] == 1) {
      Q.push(i);
    }
  }
  std ::vector<std ::pair<int, int> > res;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (d[u] < 1) continue;
    res.push_back(std ::make_pair(u, s[u]));
    s[s[u]] ^= u;
    d[s[u]] -= 1;
    if (d[s[u]] == 1) {
      Q.push(s[u]);
    }
  }
  int size = (int)res.size();
  printf("%d\n", size);
  for (int i = 0; i < size; ++i) {
    printf("%d %d\n", res[i].first, res[i].second);
  }
  return 0;
}
