#include <bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long;
bool can_win(ll s, ll e) {
  if (e % 2) return !(s % 2);
  if (s * 2 > e) {
    return ((e - s) % 2);
  }
  if (s > (e >> 2)) return true;
  return can_win(s, e >> 2);
}
bool can_lose(ll s, ll e) {
  if (s + 1 > e || s * 2 > e) return true;
  return can_win(s, e >> 1);
}
int n;
bool win[nax];
bool lose[nax];
bool f[nax];
bool g[nax];
int main() {
  scanf("%d", &n);
  ll s, e;
  f[0] = true;
  for (int x = 1; x <= n; ++x) {
    scanf("%lld %lld", &s, &e);
    win[x] = can_win(s, e);
    lose[x] = can_lose(s, e);
    if (f[x - 1] && lose[x]) f[x] = true;
    if (g[x - 1] && ((win[x] && !lose[x]) || (!win[x] && !lose[x])))
      f[x] = true;
    if (f[x - 1] && win[x]) g[x] = true;
    if (g[x - 1] && ((lose[x] && !win[x]) || (!win[x] && !lose[x])))
      g[x] = true;
  }
  printf("%d %d\n", g[n], f[n]);
}
