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