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