#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, deg[N], sum[N];
set<pair<pair<int, int>, int>> s;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> sum[i];
    s.insert(make_pair(make_pair(deg[i], sum[i]), i));
  }
  vector<pair<int, int>> ans;
  while (!s.empty()) {
    pair<pair<int, int>, int> p = (*s.begin());
    s.erase(p);
    if (!p.first.first) continue;
    int v = p.second, u = p.first.second;
    ans.push_back(make_pair(v, u));
    s.erase(make_pair(make_pair(deg[u], sum[u]), u));
    deg[u]--;
    if (deg[u] > 0) {
      sum[u] ^= v;
      s.insert(make_pair(make_pair(deg[u], sum[u]), u));
    }
  }
  cout << ans.size() << "\n";
  for (auto e : ans) cout << e.first << " " << e.second << "\n";
}
