#include <bits/stdc++.h>
using namespace std;
const int Maxn = (1 << 16) + 100;
int d[Maxn], s[Maxn];
int vis[Maxn];
int n;
vector<pair<int, int> > ans;
int main() {
  queue<int> Q;
  scanf("%d", &n);
  for (int(i) = (0); (i) <= (n - 1); ++(i)) {
    scanf("%d%d", d + i, s + i);
    if (d[i] == 1) Q.push(i);
  }
  while (Q.empty() == false) {
    int idx = Q.front();
    Q.pop();
    if (d[idx] < 1) continue;
    int adj = s[idx];
    d[adj] -= 1;
    s[adj] ^= idx;
    if (d[adj] == 1) Q.push(adj);
    ans.push_back(make_pair(idx, adj));
  }
  printf("%d\n", ans.size());
  for (auto it = ans.begin(); it != ans.end(); ++it)
    printf("%d %d\n", it->first, it->second);
  return 0;
}
