#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int res;
  scanf("%d", &res);
  return res;
}
long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }
const long long mod = 1000000007;
int deg[65536], s[65536], n, m;
queue<int> deg1;
inline void solve() {
  m = 0;
  n = nxt();
  for (int i = 0; i < n; i++) {
    deg[i] = nxt();
    s[i] = nxt();
    if (deg[i] == 1) deg1.push(i);
    m += deg[i];
  }
  cout << m / 2 << "\n";
  while (!deg1.empty()) {
    int curr = deg1.front();
    deg1.pop();
    if (deg[curr] == 1) {
      cout << curr << " " << s[curr] << "\n";
      deg[s[curr]]--;
      if (deg[s[curr]] == 1) deg1.push(s[curr]);
      s[s[curr]] ^= curr;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(4524234);
  solve();
  return 0;
}
