#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, pair<int, int> > ma[(1 << 16) + 2];
int main() {
  scanf("%d", &n);
  vector<int> que;
  for (int i = 0; i < n; i++) {
    pair<int, pair<int, int> > d;
    scanf("%d%d", &d.first, &d.second.first);
    d.second.second = i;
    if (d.first == 1) {
      que.push_back(i);
    }
    ma[i] = d;
  }
  vector<pair<int, int> > res;
  int a, b;
  while (que.size() > 0) {
    a = que[que.size() - 1];
    que.pop_back();
    if (ma[a].first == 1) {
      res.push_back(make_pair(a, ma[a].second.first));
    }
    ma[ma[a].second.first].first--;
    ma[ma[a].second.first].second.first ^= a;
    if (ma[ma[a].second.first].first == 1) {
      que.push_back(ma[a].second.first);
    }
  }
  printf("%d\n", res.size());
  for (int i = 0; i < res.size(); i++) {
    printf("%d %d\n", res[i].first, res[i].second);
  }
}
