#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 10;
int t, dp[maxn][2];
long long s[maxn], e[maxn];
bool first_win(long long s, long long e) {
  if (e % 2 == 0) {
    if (s > e / 2)
      return s % 2 == 1;
    else if (s <= e / 4)
      return first_win(s, e / 4);
    else
      return true;
  } else
    return s % 2 == 0;
}
bool first_lose(long long s, long long e) {
  if (s > e / 2)
    return true;
  else
    return first_win(s, e / 2);
}
int main() {
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) scanf("%llu %llu", &s[i], &e[i]);
  dp[0][1] = 1;
  for (int i = 1; i <= t; i++) {
    if (first_win(s[i], e[i]))
      dp[i][0] = dp[i - 1][1];
    else
      dp[i][0] = dp[i - 1][0];
    if (first_lose(s[i], e[i]))
      dp[i][1] = dp[i - 1][1];
    else
      dp[i][1] = dp[i - 1][0];
  }
  printf("%d %d", dp[t][0], dp[t][1]);
  return 0;
}
