#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 19 + 1;
struct vertex {
  int id;
  int deg, xorSum;
  bool operator<(struct vertex u) const { return deg > u.deg; }
} v[N];
int n, vis[N];
priority_queue<struct vertex> heap;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    v[i].id = i;
    scanf("%d%d", &v[i].deg, &v[i].xorSum);
  }
  for (int i = 0; i < n; i++) {
    heap.push(v[i]);
  }
  vector<pair<int, int>> ans;
  while (!heap.empty()) {
    if (vis[heap.top().id] || v[heap.top().id].deg == 0) {
      heap.pop();
      continue;
    }
    struct vertex nu = heap.top();
    heap.pop();
    vis[nu.id] = 1;
    ans.push_back(make_pair(nu.id, nu.xorSum));
    v[nu.xorSum].xorSum ^= nu.id;
    v[nu.xorSum].deg--;
    heap.push(v[nu.xorSum]);
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
