#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long INF = 8e18;
const int maxn = 5e5 + 5;
inline bool dfs(long long s, long long e) {
  if (e & 1) {
    if (s & 1)
      return 0;
    else
      return 1;
  }
  if (s > e / 2) {
    if (s & 1)
      return 1;
    else
      return 0;
  }
  if (s > e / 4) return 1;
  return dfs(s, e >> 2);
}
inline bool check(long long s, long long e) {
  if (s > e / 2) return 1;
  return dfs(s, e >> 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  bool cur = 0, win, lose;
  for (int i = 0; i < n; ++i) {
    long long s, e;
    cin >> s >> e;
    win = dfs(s, e);
    lose = check(s, e);
    win ^= cur;
    lose ^= cur;
    if (win == lose) break;
    if (win)
      cur = 1;
    else
      cur = 0;
  }
  cout << win << ' ' << lose << '\n';
  return 0;
}
