#include <bits/stdc++.h>
using namespace std;
queue<int> q;
const int maxn = 2 * 1000 * 100 + 100;
int d[maxn], x[maxn];
vector<pair<int, int> > vec;
bool check[maxn];
int main() {
  int n, m, f, g, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> x[i];
    if (d[i] == 1) {
      q.push(i);
    }
  }
  while (q.size() > 0) {
    while (q.size() > 0 && d[q.front()] == 0) q.pop();
    if (q.size() == 0) break;
    int s = q.front();
    vec.push_back(make_pair(s, x[s]));
    x[x[s]] ^= s;
    d[x[s]]--;
    if (d[x[s]] == 1) {
      q.push(x[s]);
    }
    q.pop();
  }
  cout << vec.size() << endl;
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i].first << " " << vec[i].second << endl;
  }
}
