#include <bits/stdc++.h>
using namespace std;
vector<int> G[1 << 17];
int S[1 << 17], D[1 << 17];
set<pair<int, int>> pq;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0, d, s; i < n; i++) {
    scanf("%d %d", &d, &s);
    S[i] = s;
    if (d) pq.insert({d, i});
    D[i] = d;
  }
  while (!pq.empty()) {
    int v = pq.begin()->second;
    pq.erase(pq.begin());
    int u = S[v];
    G[v].push_back(u);
    G[u].push_back(v);
    S[u] ^= v;
    pq.erase({D[u], u});
    D[u]--;
    if (D[u]) pq.insert({D[u], u});
  }
  int m = 0;
  for (int i = 0; i < n; i++) m += G[i].size();
  printf("%d\n", m / 2);
  for (int i = 0; i < n; i++)
    for (int j : G[i])
      if (i < j) printf("%d %d\n", i, j);
  return 0;
}
