#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long LINF = 2e18;
void inv(bool e);
template <typename T>
void die(T& a);
bool brute, alter;
int cnt_tests = 1;
const int N = (1 << 17) + 1;
int degree[N], xr[N];
int n;
void inp() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> xr[i];
  }
}
set<int> friends[N];
void solve() {
  for (int i = 0; i < n; i++) {
    friends[degree[i]].insert(i);
  }
  int newbie, parent;
  auto& cur = friends[1];
  vector<pair<int, int> > ans;
  while (!cur.empty()) {
    newbie = *cur.begin();
    cur.erase(cur.begin());
    parent = xr[newbie];
    friends[degree[parent]].erase(parent);
    friends[degree[parent] - 1].insert(parent);
    degree[parent]--;
    ans.push_back({newbie, parent});
    xr[parent] ^= newbie;
  }
  cout << ((int)(ans).size()) << endl;
  for (auto x : ans) {
    cout << x.first << ' ' << x.second << endl;
  }
}
void stress() {}
void naive() {}
void run();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (0) {
    freopen("stack.in", "r", stdin);
    freopen("stack.out", "w", stdout);
  }
  brute = false;
  for (int i = 0; (i < cnt_tests); i++) {
    run();
  }
  cerr << endl << "Time: " << clock() / 1000.0 << " ms";
  return 0;
}
void run() {
  if (!brute) {
    inp();
  } else {
    stress();
  }
  solve();
}
template <typename T>
void die(T& a) {
  cout << a;
  exit(0);
}
void inv(bool e) {
  if (!e) {
    vector<int> a;
    a[-1] += 1;
  }
}
