#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
struct P {
  double x, y;
  P() {}
  P(double x, double y) : x(x), y(y) {}
  P operator+(const P &a) const { return P(x + a.x, y + a.y); }
  P operator-(const P &a) const { return P(x - a.x, y - a.y); }
  double operator^(const P &a) const { return x * a.x + y * a.y; }
  void in() { scanf("%lf%lf", &x, &y); }
  void out() { printf("REQUIRED %.7f %.7f\n", x, y); }
  double dist(P a, P b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
  }
  double sqdist(P a, P b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
  }
};
struct data {
  int d, s, id;
} v[100000];
bool operator<(data u, data v) { return u.d < v.d; };
int n, m;
int a[100000], b[100000];
int q[100000];
int top, tail;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d%d", &v[i].d, &v[i].s);
  for (int i = (1); i <= (n); i++) v[i].id = i - 1;
  for (int i = (1); i <= (n); i++)
    if (v[i].d == 1) q[++top] = i;
  m = 0;
  while (tail < top) {
    int alpha = q[++tail];
    if (v[alpha].d == 1) {
      v[alpha].d--;
      a[++m] = v[alpha].id;
      b[m] = v[alpha].s;
      int qq = b[m];
      v[qq + 1].s ^= a[m];
      v[qq + 1].d--;
      if (v[qq + 1].d == 1) q[++top] = qq + 1;
    }
  }
  printf("%d\n", m);
  for (int i = (1); i <= (m); i++) printf("%d %d\n", a[i], b[i]);
  return 0;
}
