#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16;
vector<int> adj[N];
int num[N], XOR[N];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  queue<pair<int, int> > q;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    num[i] = x;
    XOR[i] = y;
    if (x == 1) {
      q.push(pair<int, int>(i, y));
    }
  }
  int cnt = 0;
  while (!q.empty()) {
    pair<int, int> front = q.front();
    q.pop();
    if (num[front.first] == 0) {
      continue;
    }
    cnt++;
    adj[front.first].push_back(front.second);
    XOR[front.second] ^= front.first;
    num[front.second]--;
    if (num[front.second] == 1) {
      q.push({front.second, XOR[front.second]});
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < int(adj[i].size()); j++)
      cout << i << " " << adj[i][j] << endl;
  }
}
