#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  stack<int> q;
  vector<pair<int, int> > sol;
  for (int i = 0; i < n; i++) {
    int d, s;
    cin >> d >> s;
    v.push_back({d, s});
    if (d == 1) q.push(i);
  }
  while (!q.empty()) {
    int x = q.top();
    q.pop();
    if (!v[x].first) continue;
    int p = v[x].second;
    sol.push_back({x, p});
    v[p].second ^= x;
    v[p].first--;
    if (v[p].first == 1) q.push(p);
  }
  cout << sol.size() << endl;
  for (auto s : sol) cout << s.first << " " << s.second << endl;
  return 0;
}
