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