#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int t;
bool fw[100010], fl[100010];
bool canwin(ll target, ll curr, bool winahead = true) {
  if (curr % 2 == 1) return (target % 2 == 0);
  if (target == curr) return false;
  if (winahead) {
    ll nxt = curr / 2;
    if (nxt % 2 == 1)
      ++nxt;
    else
      nxt += 2;
    if (target >= nxt)
      return (target % 2 == 1);
    else
      return canwin(target, nxt, false);
  } else {
    ll nxt = curr / 2;
    if (target >= nxt) return true;
    return canwin(target, nxt - 1, true);
  }
}
bool canlose(ll target, ll curr) {
  ll nxt = curr / 2;
  if (target > nxt)
    return true;
  else
    return canwin(target, nxt);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll s, e;
    cin >> s >> e;
    fw[i] = canwin(s, e);
    fl[i] = canlose(s, e);
  }
  bool answ = fw[0], ansl = fl[0];
  for (int i = 1; i < t; ++i) {
    bool wt = (ansl && fw[i]) || (answ && !fw[i]);
    bool lt = (ansl && fl[i]) || (answ && !fl[i]);
    answ = wt, ansl = lt;
  }
  cout << answ << " " << ansl << endl;
  return 0;
}
