#include <bits/stdc++.h>
using namespace std;
long long cnt[112345], xo[112345];
pair<long long, long long> out[112345];
int main() {
  multiset<pair<long long, pair<long long, long long> > > pq;
  long long n, m, i, c = 0, x, y;
  cin >> m;
  for (i = 0; i < m; i++) {
    scanf("%I64d", &x);
    scanf("%I64d", &y);
    if (x == 0) continue;
    pq.insert(make_pair(x, make_pair(i, y)));
    cnt[i] = x;
    xo[i] = y;
  }
  multiset<pair<long long, pair<long long, long long> > >::iterator it, it1;
  while ((long long)(pq.size()) >= 1) {
    it = pq.begin();
    x = (*it).first;
    i = (*it).second.first;
    y = (*it).second.second;
    out[c++] = make_pair(i, y);
    pq.erase(pq.begin());
    it1 = pq.find(make_pair(cnt[y], make_pair(y, xo[y])));
    if (it1 == pq.end()) continue;
    pq.erase(it1);
    cnt[y]--;
    xo[y] ^= i;
    if (cnt[y] != 0) pq.insert(make_pair(cnt[y], make_pair(y, xo[y])));
  }
  cout << c << endl;
  for (i = 0; i < c; i++) {
    printf("%I64d %I64d\n", out[i].first, out[i].second);
  }
  return 0;
}
