#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (1 << 16) + 10;
int d[MAX_N], s[MAX_N];
vector<pair<int, int> > ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> d[i] >> s[i];
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (d[i] == 1) q.push(i);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (d[v] == 0) continue;
    ans.push_back(make_pair(v, s[v]));
    s[s[v]] ^= v;
    d[s[v]]--;
    if (d[s[v]] == 1) q.push(s[v]);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
