#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 15 + 5;
int deg[MAXN], s[MAXN];
queue<int> q;
int main() {
  int n, sum = 0, u, v;
  cin >> n;
  while (!q.empty()) q.pop();
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> s[i];
    if (deg[i] == 1) q.push(i);
    sum += deg[i];
  }
  cout << sum / 2 << endl;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    if (deg[u] == 0) continue;
    deg[u] = 0;
    v = s[u];
    s[v] ^= u;
    deg[v]--;
    if (deg[v] == 1) q.push(v);
    cout << u << " " << v << endl;
  }
  return 0;
}
