#include <bits/stdc++.h>
using namespace std;
int pa[70000], degree[70000], s[70000], xr[70000];
queue<int> que;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  memset(pa, -1, sizeof(pa));
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> s[i];
    if (degree[i] == 1) que.push(i);
  }
  int edges = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (degree[u] != 1) continue;
    int v = s[u] ^ xr[u];
    xr[v] ^= u;
    pa[u] = v;
    edges++;
    degree[v]--;
    if (degree[v] == 1) que.push(v);
  }
  cout << edges << "\n";
  for (int u = 0; u < n; u++) {
    if (pa[u] != -1) cout << u << " " << pa[u] << "\n";
  }
  return 0;
}
