#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const double eps = (double)1e-6;
const int maxn = 2e5 + 5;
const long long mod = 1e9 + 7;
int deg[65539];
int xors[65539];
unordered_set<int> s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int degsum = 0;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xors[i];
    if (deg[i] == 1) s.insert(i);
    degsum += deg[i];
  }
  cout << degsum / 2 << endl;
  while (!s.empty()) {
    int curr = *(s.begin());
    int nei = xors[curr];
    cout << curr << " " << nei << endl;
    s.erase(curr);
    if (s.find(nei) != s.end())
      s.erase(nei);
    else {
      deg[nei]--;
      xors[nei] ^= curr;
      if (deg[nei] == 1) s.insert(nei);
    }
  }
}
