#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
int a[100001], b[100001];
int main() {
  int n;
  cin >> n;
  set<pair<int, pair<int, int> > > st;
  for (int i = 0; i < n; i++) {
    int d, s;
    scanf("%d%d", &d, &s);
    if (!d) continue;
    a[i] = d;
    b[i] = s;
    st.insert({d, {s, i}});
  }
  int cnt = 0;
  while (!st.empty()) {
    auto x = *st.begin();
    st.erase(st.begin());
    int s = x.second.first;
    int idx = x.second.second;
    adj[idx].push_back(s);
    cnt++;
    st.erase({a[s], {b[s], s}});
    a[s]--;
    b[s] ^= idx;
    if (!a[s]) continue;
    st.insert({a[s], {b[s], s}});
  }
  printf("%d\n", cnt);
  for (int i = 0; i < 100001; i++) {
    if (!adj[i].size()) continue;
    for (auto nx : adj[i]) printf("%d %d\n", i, nx);
  }
  return 0;
}
