#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
long long n, cur, x, y, xr[65540], deg[65540], cnt;
bool visited[65540];
pair<pair<long long, long long>, long long> p;
priority_queue<pair<pair<long long, long long>, long long>,
               vector<pair<pair<long long, long long>, long long>>,
               greater<pair<pair<long long, long long>, long long>>>
    pq;
vector<int> v[65540];
vector<pair<long long, long long>> ans;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    xr[i] = y;
    deg[i] = x;
    pq.push({{x, y}, i});
  }
  while (!pq.empty()) {
    p = pq.top();
    pq.pop();
    if (p.first.first == 0) {
      visited[p.second] = true;
    }
    if (visited[p.second]) continue;
    if (p.first.first <= 1) {
      long long cur = 0;
      for (int i = 0; i < v[p.second].size(); i++) cur ^= v[p.second][i];
      cur ^= p.first.second;
      ans.push_back({cur, p.second});
      v[cur].push_back(p.second);
      v[p.second].push_back(cur);
      deg[cur]--;
      pq.push({{deg[cur], xr[cur]}, cur});
    }
    visited[p.second] = true;
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
