#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  queue<int> degree1_v;
  map<int, int> degree;
  map<int, int> s;
  for (int i = 0; i < (int)(n); ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    degree[i] = a;
    s[i] = b;
    if (degree[i] == 1) degree1_v.push(i);
  }
  vector<pair<int, int>> edges;
  while (!degree1_v.empty()) {
    auto i = degree1_v.front();
    degree1_v.pop();
    if (degree[i] != 1) continue;
    edges.push_back(make_pair(i, s[i]));
    --degree[s[i]];
    s[s[i]] = s[s[i]] ^ i;
    if (degree[s[i]] == 1) {
      degree1_v.push(s[i]);
    }
  }
  cout << edges.size() << endl;
  for (auto& e : edges) {
    printf("%d %d\n", e.first, e.second);
  }
  return 0;
}
