#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 7e4;
const int INF = 1e9;
struct d {
  int ad, xr;
} a[N];
stack<int> s;
vector<pair<int, int>> v;
int n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  int A, B;
  for (int i = 0; i < n; ++i) {
    cin >> A >> B;
    if (A == 0) continue;
    if (A == 1) s.push(i);
    a[i] = {A, B};
  }
  while (!s.empty()) {
    int x = s.top();
    s.pop();
    if (a[x].ad == 1) {
      v.push_back({x, a[x].xr});
      a[x].ad--;
      --a[a[x].xr].ad;
      a[a[x].xr].xr ^= x;
      if (a[a[x].xr].ad == 1) s.push(a[x].xr);
    }
  }
  cout << v.size() << "\n";
  for (auto x : v) cout << x.first << " " << x.second << "\n";
}
