#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1000000007;
const long long linf = 0x3f3f3f3f3f3f3f3f;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ans[400100];
long long s[100100], e[100100];
int vis[400100];
int n;
void dfs(int x) {
  vis[x] = 1;
  if (x == 4 * n + 4 || x == 4 * n + 6) return;
  if (x % 4 == 0) {
    if (ans[x] && !vis[x + 6]) dfs(x + 6);
    if (ans[x + 1] && !vis[x + 4]) dfs(x + 4);
  } else {
    if (ans[x] && !vis[x + 4]) dfs(x + 4);
    if (ans[x + 1] && !vis[x + 2]) dfs(x + 2);
  }
}
int win(long long s, long long e) {
  if (e % 2) {
    if (s % 2)
      return 0;
    else
      return 1;
  }
  if (e / 2 < s && s <= e) {
    if (s % 2)
      return 1;
    else
      return 0;
  }
  if (e / 4 < s && s <= e / 2) return 1;
  return win(s, e / 4);
}
int lose(long long s, long long e) {
  if (e < 2 * s)
    return 1;
  else
    return win(s, e / 2);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i] >> e[i];
    if (win(s[i], e[i])) ans[4 * i] = 1;
    if (lose(s[i], e[i])) ans[4 * i + 1] = 1;
    if ((s[i] + 1 > e[i] || win(s[i] + 1, e[i])) &&
        (2 * s[i] > e[i] || win(2 * s[i], e[i])))
      ans[4 * i + 2] = 1;
    if ((s[i] + 1 <= e[i] && lose(s[i] + 1, e[i])) &&
        (2 * s[i] <= e[i] && lose(2 * s[i], e[i])))
      ans[4 * i + 3] = 1;
  }
  dfs(4);
  int x = vis[4 * n + 6] ? 1 : 0;
  int y = vis[4 * n + 4] ? 1 : 0;
  cout << x << " " << y << "\n";
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  ;
  solve();
  return 0;
}
