#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 16;
int n, res;
vector<pair<int, int> > v, ans;
queue<int> q;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(pair<int, int>(a, b));
  }
}
void process() {
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first == 1) q.push(i);
  }
  while (q.size()) {
    int i = q.front();
    q.pop();
    if (v[i].first < 1) continue;
    int u = v[i].second;
    ans.push_back(pair<int, int>(i, u));
    v[i].first--;
    v[u].first--;
    v[u].second ^= i;
    if (v[u].first == 1) q.push(u);
  }
}
void output() {
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  input();
  process();
  output();
  return 0;
}
