#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
bool Win(long long s, long long e) {
  if (e & 1) return !(s & 1);
  if (s > e / 2) {
    if (s & 1)
      return 1;
    else
      return 0;
  }
  if (s > e / 4) return 1;
  return Win(s, e / 4);
}
bool Lose(long long s, long long e) {
  if (s > e / 2) return 1;
  return Win(s, e / 2);
}
int main() {
  int n;
  scanf("%d", &n);
  bool sec = 0;
  int win, lose;
  for (int i = 1; i <= n; i++) {
    long long s, e;
    scanf("%lld%lld", &s, &e);
    win = Win(s, e), lose = Lose(s, e);
    win ^= sec, lose ^= sec;
    sec = win;
    if (win == lose) break;
  }
  printf("%d %d\n", win, lose);
  return 0;
}
