#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using ll = long long;
using VL = vector<ll>;
int N;
VL s, e;
void ReadData();
int GetWL(ll s, ll e);
bool Win(ll s, ll e);
bool Lose(ll s, ll e);
void Solve();
int main() {
  ReadData();
  Solve();
  return 0;
}
void ReadData() {
  cin >> N;
  s = e = VL(N);
  for (int i = 0; i < N; ++i) cin >> s[i] >> e[i];
}
int GetWL(ll s, ll e) {
  int res = 0;
  if (Win(s, e)) res += 1;
  if (Lose(s, e)) res += 2;
  return res;
}
bool Win(ll s, ll e) {
  if (e == s) return 0;
  if (e == s + 1) return 1;
  if (e & 1) return !(s & 1);
  if (s <= e / 4) return Win(s, e / 4);
  if (s > (e / 4) * 2) return ((e - s) & 1);
  return 1;
}
bool Lose(ll s, ll e) {
  if (2 * s > e) return 1;
  ll w = e / 2 + 3;
  while (w * 2 > e) --w;
  return Win(s, w);
}
void Solve() {
  VVI dp(N + 1, VI(2));
  int init = GetWL(s[0], e[0]);
  dp[0][0] = (init & 2) != 0;
  dp[0][1] = (init & 1) != 0;
  for (int i = 1; i < N; ++i) {
    int currentState = GetWL(s[i], e[i]);
    dp[i][0] = (dp[i - 1][0] && (currentState & 2)) ||
               (dp[i - 1][1] && !(currentState & 2));
    dp[i][1] = (dp[i - 1][0] && (currentState & 1)) ||
               (dp[i - 1][1] && !(currentState & 1));
  }
  cout << dp[N - 1][1] << ' ' << dp[N - 1][0] << '\n';
}
