#include <bits/stdc++.h>
const int MAX = 1e6 + 11;
using namespace std;
struct Digit {
  int c, x;
};
Digit D[MAX];
queue<int> Q;
int N;
bool W[MAX];
int main() {
  scanf("%d", &(N));
  for (int i = 0; i < (N); ++i) scanf("%d%d", &(D[i].c), &(D[i].x));
  for (int i = 0; i < (N); ++i) {
    if (D[i].c == 1) {
      Q.push(i);
    }
  }
  vector<pair<int, int>> res;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    W[v] = true;
    int w = D[v].x;
    if (W[w]) continue;
    if (v != w && D[v].c > 0 && D[w].c > 0) {
      D[v].c--;
      D[w].c--;
      D[w].x ^= v;
      if (D[w].c == 1) {
        Q.push(w);
      }
      res.push_back(make_pair(v, w));
    }
  }
  printf("%d", int((res).size()));
  for (int i = 0; i < (int((res).size())); ++i) {
    printf("\n%d %d", res[i].first, res[i].second);
  }
  return 0;
}
