#include <bits/stdc++.h>
using namespace std;
bool is_forced_win(long long int s, long long int e, bool turn);
bool is_forced_loss(long long int s, long long int e, bool turn);
bool is_forced_win(long long int s, long long int e, bool turn) {
  bool s_odd = s % 2;
  bool s_even = !s_odd;
  bool e_odd = e % 2;
  bool e_even = !e_odd;
  if (s_even && e_odd) return turn;
  if (s_odd && e_odd) return !turn;
  if (s_even && e_even) {
    if (s > e / 2)
      return !turn;
    else
      return is_forced_loss(s, e >> 1, turn);
  }
  if (s_odd && e_even) {
    if (turn)
      return is_forced_win(s + 1, e, !turn) || is_forced_win(s * 2, e, !turn);
    else
      return is_forced_win(s + 1, e, !turn) && is_forced_win(s * 2, e, !turn);
  }
  return 0;
}
bool is_forced_loss(long long int s, long long int e, bool turn) {
  if (s > e / 2)
    return turn;
  else
    return is_forced_win(s, e >> 1, turn);
}
int main() {
  int t;
  cin >> t;
  long long int s[t + 1], e[t + 1];
  for (int i = 1; i <= t; i++) {
    cin >> s[i] >> e[i];
  }
  bool force_win[t + 1], force_lose[t + 1];
  force_win[0] = 0;
  force_lose[0] = 1;
  for (int i = 1; i <= t; i++) {
    force_win[i] = (is_forced_win(s[i], e[i], 1) && force_lose[i - 1]) ||
                   (is_forced_win(s[i], e[i], 0) && force_win[i - 1]);
    force_lose[i] = (is_forced_loss(s[i], e[i], 1) && force_lose[i - 1]) ||
                    (is_forced_loss(s[i], e[i], 0) && force_win[i - 1]);
  }
  cout << force_win[t] << " " << force_lose[t] << endl;
}
