#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N = 3e5 + 10;
long long n;
long long z[N];
long long second[N];
pair<long long, long long> deg[N];
vector<pair<long long, long long> > ans;
void rec(long long v) {
  second[v] = 0;
  ans.push_back({v, z[v]});
  second[z[v]]--;
  z[z[v]] ^= v;
  if (second[z[v]] == 1) rec(z[v]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i].first >> z[i];
    second[i] = deg[i].first;
    deg[i].second = i;
  }
  sort(deg, deg + n);
  for (int i = 0; i < n; i++) {
    if (second[deg[i].second] == 1) rec(deg[i].second);
  }
  cout << ans.size() << '\n';
  for (auto u : ans) {
    cout << u.first << " " << u.second << "\n";
  }
}
