#include <bits/stdc++.h>
using namespace std;
int d[1 << 17], s[1 << 17];
int main() {
  int n;
  scanf("%d", &n);
  deque<int> q;
  vector<pair<int, int> > res;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &d[i], &s[i]);
    if (d[i] == 1) q.push_back(i);
  }
  while (q.size()) {
    int now = q.front();
    q.pop_front();
    if (!d[now]) continue;
    int nex = s[now];
    s[nex] ^= now;
    d[now]--, d[nex]--;
    res.push_back(make_pair(now, nex));
    if (d[nex] == 1) q.push_back(nex);
  }
  printf("%d\n", res.size());
  for (int i = 0; i < res.size(); i++)
    printf("%d %d\n", res[i].first, res[i].second);
  return 0;
}
