#include <bits/stdc++.h>
using namespace std;
clock_t time_p = clock();
void Time() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
const int INF = 1e9 + 7;
long double pi = 3.1415926535897932;
const long long INF64 = 9e18;
const long long mod = 1e9 + 7;
const int mxN = 2e6 + 6;
int val[mxN], deg[mxN];
int edge = 0, n;
set<pair<int, int>> st;
vector<int> ans[mxN];
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> deg[i] >> val[i];
    st.insert({deg[i], i});
  }
  while (st.size()) {
    auto it = *st.begin();
    st.erase(it);
    if (it.first == 0) continue;
    int parent = val[it.second];
    val[parent] ^= it.second;
    st.erase({deg[parent], parent});
    edge++;
    deg[parent]--;
    st.insert({deg[parent], parent});
    ans[parent].push_back(it.second);
    ans[it.second].push_back(parent);
  }
  cout << edge << endl;
  for (int i = 0; i < n; ++i) {
    for (auto it : ans[i]) {
      if (it > i) cout << it << " " << i << endl;
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.precision(15);
  cout.precision(15);
  cerr << fixed;
  cout << fixed;
  int t;
  solve();
  Time();
  return 0;
}
