#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
int p[1 << 16 + 5];
int d[1 << 16 + 5];
int x[1 << 16 + 5];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  int n;
  vector<pair<int, int> > ans;
  for (int nc = 0; nc < t; nc++) {
    cin >> n;
    queue<int> q;
    for (int i = 0; i < n; i++) {
      p[i] = -1;
      cin >> d[i] >> x[i];
      if (d[i] == 1) {
        p[i] = x[i];
        q.push(i);
      }
    }
    while (!q.empty()) {
      int aux = q.front();
      q.pop();
      int pa = p[aux];
      if (d[aux] == 0) continue;
      ans.push_back(pair<int, int>(aux, pa));
      d[pa]--;
      x[pa] ^= aux;
      if (d[pa] == 1) {
        p[pa] = x[pa];
        q.push(pa);
      }
    }
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++)
      cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
