#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long l[N], r[N];
bool dp[N][2];
bool win(long long s, long long e);
bool lose(long long s, long long e);
bool lose(long long s, long long e) {
  if (s > e / 2) return 1;
  return win(s, e / 2);
}
bool win(long long s, long long e) {
  if (e % 2 == 1) {
    if (s % 2 == 0) return 1;
    return 0;
  }
  if (s > e / 2) return (e - s) % 2;
  return lose(s, e / 2);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> l[i] >> r[i];
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (win(l[i], r[i]))
      dp[i][1] |= dp[i - 1][0];
    else
      dp[i][1] |= dp[i - 1][1];
    if (lose(l[i], r[i]))
      dp[i][0] |= dp[i - 1][0];
    else
      dp[i][0] |= dp[i - 1][1];
  }
  cout << dp[n][1] << " " << dp[n][0] << "\n";
}
