#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int MAXN = 1 << 16;
int a[MAXN], b[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, x, y;
  cin >> n;
  vector<pair<int, int> > ans;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (a[u] == 0) continue;
    int v = b[u];
    ans.push_back({u, v});
    --a[v];
    b[v] ^= u;
    if (a[v] == 1) q.push(v);
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i.first << " " << i.second << endl;
  return 0;
}
