#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n, x, a[N];
bool win(long long s, long long e) {
  if (s >= e) return s != e;
  if (e & 1) return !(s & 1);
  if (2 * s > e) return s & 1;
  if (4 * s > e) return 1;
  return win(s, e / 4);
}
bool lose(long long s, long long e) {
  if (2 * s > e) return 1;
  return win(s, e / 2);
}
int main() {
  int T;
  cin >> T;
  bool w = 1, l = 0;
  long long s, e;
  for (int i = 0; i < T; i++) {
    if (w == l) break;
    scanf("%lld%lld", &s, &e);
    bool a = win(s, e);
    bool b = lose(s, e);
    if (l) a ^= 1, b ^= 1;
    w = b;
    l = a;
  }
  cout << l << " " << w << endl;
}
