#include <bits/stdc++.h>
using namespace std;
const long long MN = 1e5 + 7;
pair<long long, long long> c[MN];
long long chk(long long s, long long e) {
  if (e == s) return 0;
  if (e == s + 1) return 1;
  if (e & 1) {
    if (s & 1) return 0;
    return 1;
  }
  if (s <= e / 4) return chk(s, e / 4);
  if (s > (e / 4) * 2)
    return ((e - s) & 1);
  else
    return 1;
}
long long lck(long long s, long long e) {
  if (s * 2 > e) return 1;
  long long w = e / 2 + 3;
  while (w * 2 > e) w--;
  return chk(s, w);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    c[i] = {chk(x, y), lck(x, y)};
  }
  long long f = 1;
  long long s = 0;
  for (long long i = 0; i < n; i++) {
    if (f == 1 && s == 1) break;
    if (f == 0 && s == 0) break;
    if (s == 1) c[i].first ^= 1, c[i].second ^= 1;
    f = c[i].second;
    s = c[i].first;
  }
  cout << s << ' ' << f << '\n';
}
