#include <bits/stdc++.h>
const int INF = 100000000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
int n;
int s[1 << 16 + 1];
int d[1 << 16 + 1];
vector<pair<int, int> > ans;
void dfs(int u) {
  if (d[u] == 0) return;
  int v = s[u];
  d[v]--;
  d[u]--;
  s[v] ^= u;
  s[u] ^= v;
  ans.push_back(pair<int, int>(u, v));
  if (d[v] == 1) dfs(v);
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> d[i] >> s[i];
  for (int i = 0; i < (n); i++) {
    if (d[i] == 1) {
      dfs(i);
    }
  }
  cout << ans.size() << endl;
  for (auto e : ans) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}
