#include <bits/stdc++.h>
using namespace std;
pair<int, int> g[500000];
vector<int> q;
vector<pair<int, int> > ans;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  q.clear();
  for (int i = 0; i < n; i++) {
    cin >> g[i].first >> g[i].second;
    if (g[i].first == 1) q.push_back(i);
  }
  ans.clear();
  for (int i = 0; i < q.size(); i++) {
    int u = q[i];
    if (g[u].first == 0) continue;
    int v = g[u].second;
    g[v].first--;
    g[v].second ^= u;
    if (g[v].first == 1) q.push_back(v);
    ans.push_back(make_pair(u, v));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
