#include <bits/stdc++.h>
using namespace std;
int degree[1 << 18 + 1];
int s[1 << 18 + 1];
int edge[1 << 18 + 1][2];
int main() {
  int n;
  queue<int> q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &degree[i], &s[i]);
    if (degree[i] == 1) q.push(i);
  }
  int x = 0;
  while (!q.empty()) {
    int k1, k2;
    k1 = q.front();
    q.pop();
    if (degree[k1] == 0) continue;
    x++;
    k2 = s[k1];
    edge[x][0] = k1;
    edge[x][1] = k2;
    degree[k2]--;
    if (degree[k2] == 1) q.push(k2);
    s[k2] = s[k2] ^ k1;
  }
  cout << x << endl;
  for (int i = 1; i <= x; i++) printf("%d %d\n", edge[i][0], edge[i][1]);
  return 0;
}
