#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 17;
int d[maxn], cat[maxn];
vector<pair<int, int> > ans;
int main() {
  int n;
  scanf("%d", &n);
  queue<int> q;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &d[i], &cat[i]);
    if (d[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (d[u] < 1) continue;
    ans.emplace_back(make_pair(u, cat[u]));
    if (d[cat[u]] > 1) cat[cat[u]] ^= u;
    if (--d[cat[u]] == 1) q.push(cat[u]);
  }
  printf("%d\n", ans.size());
  for (auto tmp : ans) printf("%d %d\n", tmp.first, tmp.second);
}
