#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int IINF = 1000000000;
const double PI = acos(-1.0);
const long long LINF = 6000000000000000000LL;
int n;
int deg[1 << 16], x[1 << 16];
class Comparator {
 public:
  bool operator()(int lhs, int rhs) {
    if (deg[lhs] != deg[rhs]) {
      return deg[lhs] < deg[rhs];
    }
    return lhs < rhs;
  }
};
void cleanup() {
  memset(x, 0, sizeof(x));
  memset(deg, 0, sizeof(deg));
}
bool Read() {
  cleanup();
  if (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; ++i) {
      scanf("%d%d", deg + i, x + i);
    }
    return true;
  }
  return false;
}
int main() {
  while (Read()) {
    set<int, Comparator> st;
    for (int i = 0; i < n; ++i) {
      st.insert(i);
    }
    vector<pair<int, int> > answer;
    while (!st.empty()) {
      int k = x[*st.begin()];
      vector<int> rem;
      while (!st.empty() && deg[*st.begin()] == 0) {
        st.erase(st.begin());
      }
      while (!st.empty() && deg[*st.begin()] == 1 && x[*st.begin()] == k) {
        rem.push_back(*st.begin());
        st.erase(st.begin());
      }
      for (int i = 0; i < rem.size(); ++i) {
        answer.push_back(make_pair(rem[i], k));
        x[k] ^= rem[i];
        st.erase(k);
        deg[k]--;
        st.insert(k);
      }
    }
    printf("%d\n", answer.size());
    for (int i = 0; i < answer.size(); ++i) {
      printf("%d %d\n", answer[i].first, answer[i].second);
    }
  }
  return 0;
}
