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