#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int t, second = 0, first = 1;
long long x, y;
bool win, loss;
bool can_win(long long s, long long e) {
  if (e & 1) return !(s & 1);
  if (s > e >> 1) return s & 1;
  if (s > e >> 2) return 1;
  return can_win(s, e >> 2);
}
bool can_loss(long long s, long long e) {
  if (s > e >> 1) return 1;
  return can_win(s, e >> 1);
}
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%lld%lld", &x, &y);
    if (first != second) {
      win = can_win(x, y);
      loss = can_loss(x, y);
      if (second) {
        win = !win;
        loss = !loss;
      }
      first = loss;
      second = win;
    }
  }
  printf("%d %d", second, first);
}
