#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > sol;
map<pair<int, int>, bool> mp;
int degree[(1 << 17)], xorsum[(1 << 17)], n, m;
int q[(1 << 17)], h = 0, t = 0;
bool vis[1 << 17];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &degree[i], &xorsum[i]);
    if (degree[i] == 1) {
      q[t++] = i;
      vis[i] = true;
    }
  }
  while (h < t) {
    int u = q[h++];
    int v = xorsum[u];
    if (!degree[u]) continue;
    degree[u]--;
    degree[v]--;
    xorsum[v] ^= u;
    if (!mp.count(make_pair(u, v)) && !mp.count(make_pair(v, u)))
      sol.push_back(make_pair(u, v));
    mp[make_pair(u, v)] = true;
    if (degree[v] == 1 && !vis[v]) {
      q[t++] = v;
      vis[v] = true;
    }
  }
  printf("%d\n", sol.size());
  for (int i = 0; i < sol.size(); i++)
    printf("%d %d\n", sol[i].first, sol[i].second);
  return 0;
}
