#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 18);
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  queue<int> Q;
  int degree[MAXN], xor_sum[MAXN];
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> xor_sum[i];
    if (degree[i] == 1) Q.push(i);
  }
  vector<pair<int, int> > E;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    if (degree[v] != 1) continue;
    xor_sum[xor_sum[v]] ^= v;
    degree[xor_sum[v]]--;
    E.push_back(make_pair(v, xor_sum[v]));
    if (degree[xor_sum[v]] == 1) Q.push(xor_sum[v]);
  }
  cout << E.size() << endl;
  for (int i = 0; i < E.size(); i++)
    cout << E[i].first << " " << E[i].second << endl;
  return 0;
}
