#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const double EPS = 1e-6;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const int INF = 1e9;
const int maxN = 1e6;
int n;
int deg[maxN], xorsum[maxN];
bool used[maxN] = {0};
queue<int> q;
vector<pair<int, int> > ed;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xorsum[i];
    if (deg[i] == 1)
      q.push(i);
    else if (deg[i] == 0)
      used[i] = 1;
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (deg[v] == 0) continue;
    used[v] = 1;
    deg[xorsum[v]]--;
    xorsum[xorsum[v]] ^= v;
    ed.push_back({v, xorsum[v]});
    if (deg[xorsum[v]] == 1) q.push(xorsum[v]);
  }
  cout << (int)ed.size() << endl;
  for (pair<int, int>& e : ed) cout << e.first << " " << e.second << endl;
}
