#include <bits/stdc++.h>
using namespace std;
int N;
int axor[1 << 16];
int degree[1 << 16], s[1 << 16];
vector<pair<int, int>> edge;
set<pair<int, int>> q;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &degree[i], &s[i]);
    q.insert({degree[i], i});
  }
  for (int i = 0; i < N; i++) {
    int x, y;
    x = (*q.begin()).second;
    if (degree[x] == 0) {
      q.erase({degree[x], x});
      continue;
    }
    if (degree[x] > 1)
      while (true)
        ;
    y = s[x] ^ axor[x];
    axor[x] ^= y;
    if (axor[x] != s[x])
      while (true)
        ;
    axor[y] ^= x;
    q.erase({degree[y], y});
    q.erase({degree[x], x});
    degree[x]--;
    degree[y]--;
    q.insert({degree[y], y});
    if (x == y)
      while (true)
        ;
    edge.push_back({x, y});
  }
  for (int i = 0; i < N; i++)
    if (axor[i] != s[i])
      while (true)
        ;
  printf("%d\n", edge.size());
  for (auto i : edge) {
    printf("%d %d\n", i.first, i.second);
  }
  return 0;
}
