#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
long long powm(long long a, long long p, long long m) {
  long long r = 1 % m;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
int d[1 << 16], s[1 << 16], xo[1 << 16], uses[1 << 16];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> cur;
  for (int i = 0; i < (n); ++i) {
    scanf("%d%d", d + i, s + i);
    if (d[i] == 1) {
      cur.push_back(i);
      uses[i] = 1;
    }
  }
  set<pair<int, int> > ans;
  while (((int)(cur).size())) {
    vector<int> tmp;
    for (int i = 0; i < (((int)(cur).size())); ++i) {
      int v = cur[i];
      if (d[v] != 1) {
        uses[v] = 0;
        continue;
      }
      int u = s[v] ^ xo[v];
      if (v < u)
        ans.insert(make_pair(v, u));
      else
        ans.insert(make_pair(u, v));
      xo[u] ^= v;
      if (!uses[u]) tmp.push_back(u);
      uses[u] = 1;
      d[u]--;
    }
    cur = tmp;
  }
  printf("%d\n", ((int)(ans).size()));
  for (set<pair<int, int> >::iterator it = ans.begin(); it != ans.end(); ++it)
    printf("%d %d\n", it->first, it->second);
  return 0;
}
