#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
struct Q {
  int a, b, c;
  Q(int a, int b, int c) : a(a), b(b), c(c) {}
  bool operator<(const Q& o) const {
    if (a == o.a) return c < o.c;
    return a < o.a;
  }
};
vector<pair<int, int> > ans;
set<Q> q;
int in[100000];
int main() {
  int n, i, a, b;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d%d", &a, &b);
    in[i] = a;
    if (a) q.insert(Q(a, b, i));
  }
  while (!q.empty()) {
    Q u = *(q.begin());
    q.erase(q.begin());
    int cur = u.c;
    ans.push_back(make_pair(u.b, u.c));
    in[u.b]--;
    in[u.c]--;
    u = *q.lower_bound(Q(in[u.b] + 1, 0, u.b));
    q.erase(u);
    u.a--;
    u.b ^= cur;
    if (u.a) q.insert(u);
  }
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
