#include <bits/stdc++.h>
using namespace std;
struct nodes {
  int degree;
  int s;
} node[66000];
int vis[66000];
queue<int> q;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> node[i].degree >> node[i].s;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (node[i].degree == 1) q.push(i);
    sum += node[i].degree;
  }
  cout << sum / 2 << endl;
  while (!q.empty()) {
    int now = q.front();
    int nowto = node[now].s;
    q.pop();
    if (vis[now]) continue;
    node[nowto].s ^= now;
    node[nowto].degree--;
    if (node[nowto].degree == 1)
      q.push(nowto);
    else if (node[nowto].degree == 0)
      vis[nowto] = 1;
    cout << now << " " << nowto << endl;
  }
  return 0;
}
