#include <bits/stdc++.h>
using namespace std;
void judge() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  int t = 1;
  judge();
  while (t--) {
    int n;
    cin >> n;
    vector<int> m(n);
    vector<int> done(n);
    queue<int> q;
    vector<int> tr(n);
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      m[i] = b;
      done[i] = a;
      if (a == 1) q.push(i), tr[i]++;
    }
    vector<int> g[n];
    int ret = 0;
    map<pair<int, int>, int> ans;
    while (!q.empty()) {
      auto x = q.front();
      q.pop();
      if (done[x] == 0) continue;
      ans[{x, m[x]}]++;
      ret++;
      if (x == m[x]) ret--, g[x].pop_back();
      m[m[x]] ^= x;
      done[m[x]]--;
      if (done[m[x]] == 1) q.push(m[x]);
    }
    cout << ans.size() << endl;
    for (auto i : ans) {
      cout << i.first.first << " " << i.first.second << endl;
    }
  }
}
