#include <bits/stdc++.h>
const size_t max_vertices = 1 << 16;
int degree[max_vertices], xor_sum[max_vertices];
std::queue<int> queue;
std::vector<std::pair<int, int>> result;
int main() {
  int vcount = 0;
  std::cin >> vcount;
  for (int i = 0; i < vcount; i++) {
    std::cin >> degree[i] >> xor_sum[i];
    if (degree[i] == 1) {
      queue.push(i);
    }
  }
  while (!queue.empty()) {
    int cur = queue.front();
    queue.pop();
    int next = xor_sum[cur];
    if (degree[cur] > 0 && degree[next] > 0) {
      result.push_back(std::make_pair(cur, next));
      degree[next]--;
      degree[cur]--;
      xor_sum[next] ^= cur;
    }
    if (degree[next] == 1) {
      queue.push(next);
    }
  }
  std::cout << result.size() << std::endl;
  for (int i = 0; i < result.size(); i++) {
    std::cout << result[i].first << " " << result[i].second << std::endl;
  }
  return 0;
}
