#include <bits/stdc++.h>
using namespace std;
int mas[100010][2];
vector<string> ans;
int main() {
  int n;
  cin >> n;
  queue<int> st;
  for (int i = 0; i < n; i++) {
    cin >> mas[i][0] >> mas[i][1];
    if (mas[i][0] == 1) {
      st.push(i);
    }
  }
  while (st.size()) {
    int t = st.front();
    st.pop();
    int v = mas[t][1];
    if (mas[t][0] == 0) {
      continue;
    }
    mas[v][0] -= 1;
    mas[v][1] ^= t;
    ans.push_back(to_string(v) + " " + to_string(t));
    if (mas[v][0] == 1) {
      st.push(v);
    }
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    printf("%s\n", x.c_str());
  }
  return 0;
}
