#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long fp(long long a, long long b) {
  if (b == 0) return 1;
  long long x = fp(a, b / 2);
  x = (x * x) % mod;
  if (b & 1) x = (x * a) % mod;
  return x;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, d, v;
  cin >> n;
  long long ar[n][2];
  set<array<long long, 3>> s;
  for (long long i = 0; i < n; i++) {
    cin >> d >> v;
    ar[i][0] = d;
    ar[i][1] = v;
    s.insert({d, i, v});
  }
  vector<array<long long, 2>> edge;
  vector<vector<long long>> G(n);
  while (s.size() > 1) {
    auto it = *s.begin();
    s.erase(it);
    if (it[0] == 0) continue;
    edge.push_back({it[1], it[2]});
    s.erase({ar[it[2]][0], it[2], ar[it[2]][1]});
    ar[it[2]][1] ^= it[1];
    ar[it[2]][0]--;
    s.insert({ar[it[2]][0], it[2], ar[it[2]][1]});
  }
  cout << edge.size() << "\n";
  for (auto i : edge) {
    cout << i[0] << " " << i[1] << "\n";
  }
}
