#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 16 + 2;
int deg[maxn], xorsum[maxn];
vector<pair<int, int> > ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xorsum[i];
    if (deg[i] == 0) continue;
    if (deg[i] == 1) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    int temp = q.front();
    q.pop();
    if (deg[temp] == 0) continue;
    deg[temp]--;
    int to = xorsum[temp];
    ans.push_back(make_pair(to, temp));
    deg[to]--;
    xorsum[to] ^= temp;
    if (deg[to] == 1) q.push(to);
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
