#include <bits/stdc++.h>
using namespace std;
const int Maxn = 65536 + 10;
int n, deg[Maxn], s[Maxn];
vector<pair<int, int> > ans;
set<pair<int, int> > mys;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &deg[i], &s[i]);
    mys.insert(make_pair(deg[i], i));
  }
  while (!mys.empty()) {
    pair<int, int> p = *mys.begin();
    mys.erase(p);
    if (p.first > 0) {
      ans.push_back(make_pair(p.second, s[p.second]));
      mys.erase(make_pair(deg[s[p.second]], s[p.second]));
      deg[s[p.second]]--;
      s[s[p.second]] ^= p.second;
      mys.insert(make_pair(deg[s[p.second]], s[p.second]));
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d \n", ans[i].first, ans[i].second);
  return 0;
}
