#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
A cvt(B x) {
  stringstream ss;
  ss << x;
  A y;
  ss >> y;
  return y;
}
int n;
int d[1 << 16], x[1 << 16];
int main() {
  scanf("%d", &n);
  queue<int> q;
  for (int i = 0; i < (n); i++) {
    scanf("%d %d", &d[i], &x[i]);
    if (d[i] == 1) q.push(i);
  }
  vector<pair<int, int> > f;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    if (d[i] != 1) continue;
    int j = x[i];
    f.push_back({i, j});
    x[j] ^= i;
    d[j]--;
    if (d[j] == 1) q.push(j);
  }
  printf("%d\n", f.size());
  for (auto ij : f) {
    printf("%d %d\n", ij.first, ij.second);
  }
  return 0;
}
