#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n;
int val[maxn], du[maxn];
queue<int> q;
vector<pair<int, int> > v;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", du + i, val + i);
  }
  for (int i = 0; i < n; i++) {
    if (du[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int z = q.front();
    q.pop();
    int now = val[z];
    if (du[z] <= 0) continue;
    if (du[now] >= 1) {
      du[z]--;
      du[now]--;
      v.push_back(make_pair(z, now));
      val[now] ^= z;
    }
    if (du[now] == 1) q.push(now);
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
