#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
const long long LLINF = numeric_limits<long long>::max();
const unsigned long long ULLINF = numeric_limits<unsigned long long>::max();
vector<vector<int>> g;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    int d, b;
    cin >> d >> b;
    a[i] = {d, b};
  }
  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (a[i].first == 1) q.push(i);
  }
  vector<pair<int, int>> ans;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (a[v].first == 0) continue;
    ans.push_back({v, a[v].second});
    a[a[v].second].first--;
    a[a[v].second].second ^= v;
    if (a[a[v].second].first == 1) q.push(a[v].second);
  }
  cout << ans.size() << "\n";
  for (auto k : ans) cout << k.first << " " << k.second << "\n";
  return 0;
}
