#include <bits/stdc++.h>
using namespace std;
struct Item {
  int degree;
  int s;
  int vertex;
};
struct Cmp {
  bool operator()(const Item& lhs, const Item& rhs) const {
    if (lhs.degree != rhs.degree) {
      return lhs.degree < rhs.degree;
    }
    if (lhs.s != rhs.s) {
      return lhs.s < rhs.s;
    }
    return lhs.vertex < rhs.vertex;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  set<Item, Cmp> st;
  map<int, Item> m;
  for (int i = 0; i < N; ++i) {
    int degree, s;
    cin >> degree >> s;
    Item item = {degree, s, i};
    st.insert(item);
    m[i] = item;
  }
  vector<pair<int, int>> answer;
  while (!st.empty()) {
    Item item = *st.begin();
    st.erase(st.begin());
    m.erase(item.vertex);
    if (item.degree == 0) {
      continue;
    }
    assert(item.degree == 1);
    answer.push_back({item.vertex, item.s});
    assert(m.count(item.s));
    Item& u_item = m[item.s];
    st.erase(u_item);
    --u_item.degree;
    u_item.s ^= item.vertex;
    st.insert(u_item);
  }
  cout << answer.size() << '\n';
  for (const auto& e : answer) {
    cout << e.first << ' ' << e.second << '\n';
  }
  return 0;
}
