#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16;
int degree[N];
int sum[N];
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> degree[i] >> sum[i];
  }
  vector<pair<int, int> > edges;
  queue<int> q;
  for (int i = 0; i < n; ++i)
    if (degree[i] == 1) {
      q.push(i);
    }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (degree[u] != 1) continue;
    int v = sum[u];
    edges.push_back(make_pair(u, v));
    sum[v] ^= u;
    if (--degree[v] == 1) {
      q.push(v);
    }
  }
  printf("%d\n", (int)edges.size());
  for (int i = 0; i < (int)edges.size(); ++i) {
    printf("%d %d\n", edges[i].first, edges[i].second);
  }
  return 0;
}
