#include <bits/stdc++.h>
using namespace std;
long long s[100005], e[100005];
int W[100005], L[100005];
bool can_win(long long n, long long x, bool alter, bool start) {
  if (n / 2 + 1 <= x && x <= n) {
    if (alter) {
      long long d = (n - x + 1);
      return (d + start + 1) % 2;
    } else
      return 1;
  } else {
    long long m = n / 2;
    if (alter) {
      int a = 0, b = 0;
      if (m * 2 == n)
        a = start;
      else
        a = 1 - start;
      long long d = n - (n / 2 + 1) + 1;
      b = (d + start + 1) % 2;
      if (a == 0)
        return can_win(m, x, 0, 1);
      else {
        if (b == 0)
          return can_win(m, x, 1, 1);
        else
          return can_win(m, x, 1, 0);
      }
    } else
      return can_win(m, x, 1, 0);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &s[i], &e[i]);
    W[i] = can_win(e[i], s[i], 1, 0);
    L[i] = can_win(e[i], s[i], 0, 1);
  }
  int w = W[n], l = L[n];
  for (int i = n - 1; i >= 1; i--) {
    if ((W[i] == 1 && w == 0) || (L[i] == 1 && w == 1))
      w = 1;
    else
      w = 0;
    if ((W[i] == 1 && l == 0) || (L[i] == 1 && l == 1))
      l = 1;
    else
      l = 0;
  }
  printf("%d %d\n", w, l);
}
