#include <bits/stdc++.h>
using namespace std;
const int nm = 65538;
int n;
pair<int, int> a[nm];
queue<int> q;
bool inq[nm];
pair<int, int> kq[nm];
int nkq;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    if (a[i].first == 1) {
      q.push(i);
      inq[i] = 1;
    }
  }
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    if (a[i].first != 1) continue;
    int j = a[i].second;
    nkq++;
    kq[nkq].first = i;
    kq[nkq].second = j;
    a[j].first--;
    a[j].second ^= i;
    if (a[j].first == 1 && !inq[j]) {
      q.push(j);
      inq[j] = 1;
    }
  }
  printf("%d\n", nkq);
  for (int i = 1; i <= nkq; ++i) printf("%d %d\n", kq[i].first, kq[i].second);
}
