#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[n], s[n];
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > res;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (d[v] == 0) continue;
    int to = s[v];
    res.push_back({v, to});
    s[to] ^= v;
    d[to]--;
    if (d[to] == 1) q.push(to);
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) {
    cout << res[i].first << ' ' << res[i].second << endl;
  }
  return 0;
}
