#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 200005;
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powb(long long a, long long b) {
  long long res = 1;
  a;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    a = a * a;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<int> g[N];
int deg[N], x[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  set<pair<int, int> > s;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> x[i];
    s.insert({deg[i], i});
  }
  int ed = 0;
  for (int i = 0; i < n; i++) ed += deg[i];
  ed /= 2;
  while (!s.empty()) {
    auto rem = *(s.begin());
    s.erase(s.begin());
    if (rem.first == 0) continue;
    int par = x[rem.second];
    s.erase({deg[par], par});
    deg[par]--;
    x[par] ^= rem.second;
    s.erase(rem);
    s.insert({deg[par], par});
    g[par].push_back(rem.second);
    g[rem.second].push_back(par);
  }
  cout << ed << "\n";
  int ct = 0;
  for (int i = 0; i < n; i++) {
    for (auto j : g[i]) {
      if (j > i) {
        ct++;
        cout << i << " " << j << "\n";
      }
    }
  }
  assert(ct == ed);
}
