#include <bits/stdc++.h>
using namespace std;
typedef struct vertex {
  int deg, val;
} vertex;
int main() {
  int n, edges = 0;
  cin >> n;
  vector<vertex> vertices(1 << 16);
  deque<int> degree_one;
  for (int i = 0; i < n; i++) {
    cin >> vertices[i].deg >> vertices[i].val;
    edges += vertices[i].deg;
    if (vertices[i].deg == 1) {
      degree_one.push_back(i);
    }
  }
  cout << edges / 2 << endl;
  int a, b;
  while (!degree_one.empty()) {
    a = degree_one.front();
    degree_one.pop_front();
    if (vertices[a].deg == 0) continue;
    b = vertices[a].val;
    cout << a << " " << b << endl;
    vertices[b].val ^= a;
    if (--vertices[b].deg == 1) degree_one.push_back(b);
  }
  return 0;
}
