#include <bits/stdc++.h>
bool canWin(long long b, long long e) {
  if (e % 2 == 1) {
    return b % 2 == 0;
  } else if (e < 2 * b) {
    return b % 2 == 1;
  } else if (e < 4 * b) {
    return 1;
  } else {
    return canWin(b, e / 4);
  }
}
bool canLose(long long b, long long e) {
  if (e < 2 * b) {
    return 1;
  } else if (e / 2 % 2 == 1) {
    return b % 2 == 0;
  } else if (e < 4 * b) {
    return b % 2 == 1;
  } else {
    return canLose(b, e / 4);
  }
}
int main() {
  int t;
  scanf("%d", &t);
  bool canBeWinner, canBeLoser;
  bool canBeFirst = true;
  bool canBeSecond = false;
  for (int i = 0; i < t; i++) {
    long long b, e;
    scanf("%lld%lld", &b, &e);
    bool cWin = canWin(b, e);
    bool cLose = canLose(b, e);
    canBeWinner = (canBeFirst && cWin) || (canBeSecond && !cWin);
    canBeLoser = (canBeFirst && cLose) || (canBeSecond && !cLose);
    canBeFirst = canBeLoser;
    canBeSecond = canBeWinner;
  }
  printf("%d %d\n", canBeWinner, canBeLoser);
  return 0;
}
