#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const long long N = 2e5 + 5, MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long deg[n], sum[n];
  queue<long long> q;
  for (long long i = 0; i < n; i++) {
    cin >> deg[i] >> sum[i];
    if (deg[i] == 1) q.push(i);
  }
  vector<pair<long long, long long> > ans;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    if (deg[u] == 0) continue;
    deg[u]--;
    long long v = sum[u];
    ans.push_back({u, v});
    sum[v] ^= u;
    deg[v]--;
    if (deg[v] == 1) q.push(v);
  }
  cout << ans.size() << "\n";
  for (auto& ele : ans) cout << ele.first << " " << ele.second << "\n";
}
