#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9;
int S[70000], st[70000], d[70000];
vector<pair<int, int> > v;
int main() {
  int n, i, nv, second, x, y, sum, top = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> d[i] >> S[i];
    if (d[i] == 1) st[top++] = i;
  }
  while (top > 0) {
    top--;
    x = st[top];
    if (d[x] != 1) continue;
    y = S[x];
    S[y] = S[y] ^ x;
    d[y]--;
    if (d[y] == 1) st[top++] = y;
    v.push_back(make_pair(x, y));
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
  return 0;
}
