#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > ans;
set<long long> st;
set<long long>::iterator it, op;
long long tot_xor[500007], tot_adj[500007];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, cnt = 0;
  cin >> n;
  cnt = n;
  for (long long i = 0; i < n; ++i) {
    cin >> tot_adj[i] >> tot_xor[i];
    if (tot_adj[i] == 1) st.insert(i);
  }
  while (st.size()) {
    vector<long long> leaf;
    for (it = st.begin(); it != st.end(); ++it) {
      if (tot_adj[*it] == 0) continue;
      ans.push_back(make_pair(*it, tot_xor[*it]));
      tot_adj[tot_xor[*it]]--;
      leaf.push_back(tot_xor[*it]);
      tot_xor[tot_xor[*it]] ^= *it;
    }
    st.clear();
    for (long long i = 0; i < leaf.size(); ++i)
      if (tot_adj[leaf[i]] == 1) st.insert(leaf[i]);
  }
  cout << ans.size() << "\n";
  for (long long i = 0; i < ans.size(); ++i)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
