#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MINF = 0x80000000;
const int mod = 1000000007;
const int cons = 100001;
vector<pair<pair<int, int>, int> > info;
vector<int> edge[cons];
int main() {
  int n, num = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    info.push_back({{x, y}, i});
  }
  for (int i = 0; i < n; i++) {
    if (info[i].first.first == 0) continue;
    if (info[i].first.first > 1) continue;
    int now = i;
    while (info[now].first.first == 1) {
      edge[now].push_back(info[now].first.second);
      num++;
      info[info[now].first.second].first.first--;
      info[info[now].first.second].first.second ^= now;
      info[now].first.first = 0;
      now = info[now].first.second;
    }
  }
  printf("%d\n", num);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < edge[i].size(); j++) {
      printf("%d %d\n", i, edge[i][j]);
    }
  }
  return 0;
}
