#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int de[maxn], xorm[maxn];
int way[maxn][2];
int main() {
  int n;
  cin >> n;
  queue<int> mq;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> de[i] >> xorm[i];
    if (de[i] == 1) {
      mq.push(i);
    }
  }
  while (!mq.empty()) {
    int t1 = mq.front();
    mq.pop();
    if (de[t1] == 0) continue;
    int t2 = xorm[t1];
    way[++cnt][0] = t1;
    way[cnt][1] = t2;
    de[t2]--;
    if (de[t2] == 1) mq.push(t2);
    xorm[t2] = xorm[t2] ^ t1;
  }
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i++) cout << way[i][0] << " " << way[i][1] << endl;
  return 0;
}
