#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int mod = 1e9 + 9;
const int N = (1 << 16) + 5;
int n;
struct node {
  int du, z, id;
} c[N];
queue<node> q;
vector<pair<int, int> > p;
vector<pair<int, int> >::iterator it;
void bfs() {
  for (int i = 0; i < n; i++) {
    if (c[i].du == 1) {
      q.push(c[i]);
    }
  }
  node x;
  int u, v;
  while (!q.empty()) {
    x = q.front();
    q.pop();
    u = x.id;
    v = x.z;
    if (c[v].du > 0)
      p.push_back(make_pair(u, v));
    else
      continue;
    c[u].du--;
    c[v].du--;
    c[v].z ^= c[u].id;
    if (c[v].du == 1) {
      q.push(c[v]);
    }
  }
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &c[i].du, &c[i].z);
      c[i].id = i;
    }
    bfs();
    cout << p.size() << endl;
    for (it = p.begin(); it != p.end(); it++) {
      printf("%d %d\n", it->first, it->second);
    }
  }
  return 0;
}
