#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long w = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar();
  return w;
}
long long n, s[100005], e[100005];
bool f[100005][2];
bool check(long long x, long long y, long long op) {
  if ((y & 1) && (!op)) return (y - x) & 1;
  long long h = y >> 1;
  if (x > h) return op ? 1 : (y - x) & 1;
  return check(x, h, op ^ 1);
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++)
    s[i] = read(), e[i] = read(), f[i][0] = check(s[i], e[i], 0),
    f[i][1] = check(s[i], e[i], 1);
  bool need = f[n][0];
  for (long long i = n - 1; i > 0; i--) need = f[i][need];
  printf(need ? "1 " : "0 ");
  need = f[n][1];
  for (long long i = n - 1; i > 0; i--) need = f[i][need];
  printf(need ? "1" : "0");
  return 0;
}
