#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
int n, x[70000], c[70000];
bool was[70000];
void dfs(int v, int p) {
  if (p != -1) {
    ans.push_back(make_pair(p, v));
    c[v]--;
    x[v] ^= p;
  }
  if (c[v] == 1) {
    int go = x[v];
    c[v] = 0;
    dfs(go, v);
  }
}
int main() {
  memset(was, 0, sizeof was);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", c + i, x + i);
  }
  bool f = true;
  while (f) {
    f = false;
    for (int i = 0; i < n; i++) {
      if (c[i] == 1) {
        was[i] = true;
        f = true;
        dfs(i, -1);
      }
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
