#include <bits/stdc++.h>
using namespace std;
int d[1000000], s[1000000];
int main() {
  int n;
  scanf("%d", &n);
  queue<int> q;
  for (int i = (0); i < int(n); ++i) {
    scanf("%d%d", d + i, s + i);
    if (d[i] == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > ans;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (!d[cur]) continue;
    int to = s[cur];
    --d[to];
    s[to] ^= cur;
    if (d[to] == 1) q.push(to);
    ans.push_back({cur, to});
  }
  printf("%d\n", ans.size());
  for (int i = (0); i < int(ans.size()); ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
