#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, L = 20, MOD = 1e9 + 7, P = 727;
const long long inf = 2e19 + 10;
int p[100000], d[100000], xa[100000];
set<pair<int, int> > s;
vector<pair<int, int> > A;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> xa[i];
    if (d[i] != 0) s.insert(make_pair(d[i], i));
  }
  while (s.size()) {
    pair<int, int> a = (*s.begin());
    int v = xa[a.second];
    A.push_back(make_pair(v, a.second));
    xa[v] ^= a.second;
    s.erase(make_pair(d[v], v));
    d[v]--;
    if (d[v] != 0) s.insert(make_pair(d[v], v));
    s.erase(a);
  }
  cout << A.size() << '\n';
  for (int i = 0; i < A.size(); i++) {
    cout << A[i].first << ' ' << A[i].second << '\n';
  }
  return 0;
}
