#include <bits/stdc++.h>
using namespace std;
int pos[65536], deg[65536], s[65536];
vector<int> node[65536];
vector<pair<int, int>> res;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", deg + i, s + i);
    pos[i] = node[deg[i]].size();
    node[deg[i]].push_back(i);
  }
  for (; node[1].size();) {
    int a = node[1].back();
    node[1].pop_back();
    int b = s[a];
    res.push_back({a, b});
    node[deg[b]][pos[b]] = node[deg[b]].back();
    pos[node[deg[b]][pos[b]]] = pos[b];
    --deg[b];
    pos[b] = node[deg[b]].size();
    node[deg[b]].push_back(b);
    node[deg[b] + 1].pop_back();
    s[b] ^= a;
  }
  printf("%d\n", res.size());
  for (auto p : res) {
    printf("%d %d\n", p.first, p.second);
  }
  return 0;
}
