#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const int maxm = 55;
const int inf = 2147483647;
const int p = 1000000007;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
int win(long long s, long long e) {
  if (e % 2ll == 1) {
    if (s % 2ll == 1)
      return 0;
    else
      return 1;
  }
  if (s > e / 2ll) {
    if (s % 2ll == 1)
      return 1;
    else
      return 0;
  }
  if (s > e / 4ll && s <= e / 2ll) return 1;
  return win(s, e / 4ll);
}
int los(long long s, long long e) {
  if (s > e / 2ll) return 1;
  return win(s, e / 2ll);
}
int main() {
  int t;
  scanf("%d", &t);
  int w = 0, l = 1;
  while (t--) {
    long long s, e;
    scanf("%lld%lld", &s, &e);
    int wi = win(s, e), lo = los(s, e), ww = 0, llo = 0;
    if (w) ww |= (wi ^ 1), llo |= (lo ^ 1);
    if (l) ww |= wi, llo |= lo;
    w = ww, l = llo;
  }
  printf("%d %d\n", w, l);
}
