#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 17;
int n;
int deg[N], sum[N];
vector<pair<int, int> > ans;
void solve() {
  queue<int> q;
  for (int i = int(0); i < int(n); i++) {
    if (deg[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (deg[u] == 0) continue;
    int v = sum[u];
    sum[v] = sum[v] ^ u;
    --deg[v];
    --deg[u];
    if (deg[v] == 1) {
      q.push(v);
    }
    ans.push_back(pair<int, int>(u, v));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = int(0); i < int(n); i++) {
    cin >> deg[i] >> sum[i];
  }
  solve();
  cout << ans.size();
  for (pair<int, int> uv : ans) cout << "\n" << uv.first << " " << uv.second;
  cout << "\n";
  return 0;
}
