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