#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const ll N = 2e5 + 10;
ll S[N], E[N], cur, l, w, T;
inline ll Win(ll S, ll E) {
  if (E & 1) {
    if (S & 1) return 0;
    return 1;
  }
  if (S > E / 2) {
    if (S & 1) return 1;
    return 0;
  }
  if (S > E / 4) return 1;
  return Win(S, E >> 2);
}
inline ll Lose(ll S, ll E) {
  if (S > E / 2) return 1;
  return Win(S, E >> 1);
}
int main() {
  T = read();
  for (ll i = 1; i <= T; i++) {
    S[i] = read();
    E[i] = read();
  }
  for (ll i = 1; i <= T; i++) {
    w = Win(S[i], E[i]);
    l = Lose(S[i], E[i]);
    w ^= cur;
    l ^= cur;
    if (w == l) break;
    if (w)
      cur = 1;
    else
      cur = 0;
  }
  printf("%lld %lld\n", w, l);
  return 0;
}
