#include <bits/stdc++.h>
using namespace std;
const int Maxn = (1 << 16) + 10;
int n;
int c[Maxn], deg[Maxn];
set<pair<int, int> > s;
vector<pair<int, int> > ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> c[i];
    s.insert(make_pair(deg[i], i));
  }
  while (s.size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    if (deg[v]) {
      int u = c[v];
      s.erase(make_pair(deg[u], u));
      deg[u]--;
      ans.push_back(make_pair(u, v));
      c[u] = c[u] ^ v;
      s.insert(make_pair(deg[u], u));
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
