#include <bits/stdc++.h>
using namespace std;
const int maxn = 99999;
int d[maxn], s[maxn];
int n;
int m;
queue<int> q;
vector<pair<int, int> > p;
bool inq[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &d[i], &s[i]), m += d[i];
    if (d[i] == 1) q.push(i);
  }
  m /= 2;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (d[x] <= 0) continue;
    int y = s[x];
    p.push_back(make_pair(x, y));
    s[y] ^= x;
    d[y]--;
    if (d[y] == 1) q.push(s[x]);
  }
  printf("%d\n", p.size());
  for (int i = 0; i < p.size(); i++) printf("%d %d\n", p[i].first, p[i].second);
  return 0;
}
