#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  vector<int64_t> S(T);
  vector<int64_t> E(T);
  for (int i = 0; i < T; ++i) cin >> S[i] >> E[i];
  function<int(int64_t, int64_t)> f = [&](int64_t s, int64_t e) -> int {
    if (e & 1) return ~s & 1;
    if (s * 2 > e) return s & 1;
    if (s * 4 > e) return 1;
    return f(s, e / 4);
  };
  int w = f(S.back(), E.back());
  int l = 2 * S.back() > E.back() || f(S.back(), E.back() / 2);
  for (int i = T - 2; ~i; --i) {
    int a = f(S[i], E[i]);
    int b = 2 * S[i] > E[i] || f(S[i], E[i] / 2);
    tie(w, l) = make_pair((a & !w) | (b & w), (a & !l) | (b & l));
  }
  cout << w << " " << l << endl;
  return 0;
}
