#include <bits/stdc++.h>
using namespace std;
bool win(long long e, long long s) {
  if (e & 1) {
    return !(s & 1);
  } else {
    long long low = e / 2 + 1;
    if (s >= low) {
      return (s & 1);
    } else {
      low = e / 4 + 1;
      if (s >= low)
        return 1;
      else
        return win(e / 4, s);
    }
  }
}
bool lose(long long e, long long s) {
  long long dw = e / 2 + 1;
  if (s >= dw) return 1;
  return win(e / 2, s);
}
bool dp[100004][2] = {0};
long long s[100004], e[100004];
int main() {
  dp[0][1] = 1;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld%lld", &s[i], &e[i]);
  }
  for (int i = 1; i <= n; ++i) {
    bool fir_can_win = win(e[i], s[i]);
    bool fir_can_lose = lose(e[i], s[i]);
    if (fir_can_win) dp[i][0] |= dp[i - 1][1];
    if (fir_can_lose) dp[i][1] |= dp[i - 1][1];
    if (!fir_can_win) dp[i][0] |= dp[i - 1][0];
    if (!fir_can_lose) dp[i][1] |= dp[i - 1][0];
  }
  if (dp[n][0])
    printf("1 ");
  else
    printf("0 ");
  if (dp[n][1])
    printf("1\n");
  else
    printf("0\n");
}
