#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
long long a[N], b[N];
int f[N][2];
long long WIN(long long x, long long y) {
  assert(x <= y);
  if (y & 1) return !(x & 1);
  if (x * 2 > y) return x & 1;
  if (x * 4 > y) return 1;
  return WIN(x, y / 4);
}
long long LOSE(long long x, long long y) {
  assert(x <= y);
  if (x * 2 > y) return 1;
  return WIN(x, y / 2);
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%lld%lld", &a[i], &b[i]);
  f[n][0] = WIN(a[n], b[n]);
  f[n][1] = LOSE(a[n], b[n]);
  for (int i = (int)(n - 1); i >= (int)(1); i--) {
    if (f[i + 1][0] == 0 && WIN(a[i], b[i])) f[i][0] = 1;
    if (f[i + 1][0] == 1 && LOSE(a[i], b[i])) f[i][0] = 1;
    if (f[i + 1][1] == 0 && WIN(a[i], b[i])) f[i][1] = 1;
    if (f[i + 1][1] == 1 && LOSE(a[i], b[i])) f[i][1] = 1;
  }
  cout << f[1][0] << ' ' << f[1][1] << endl;
}
