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