#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inf = 1LL << 50;
const int N = 100000;
bool canWin(long long curr, long long e) {
  if (curr > e) {
    return true;
  }
  while (e % 2 == 0) {
    if (curr > e / 2) {
      return curr % 2;
    }
    e /= 2;
    if (curr > e / 2) {
      return true;
    }
    e /= 2;
  }
  return !(curr % 2);
}
bool canLose(long long curr, long long e) {
  if (curr > e) {
    return false;
  }
  if (curr > e / 2) {
    return true;
  }
  return canWin(curr, e / 2);
}
pair<long long, long long> rounds[N];
bool dp[N][4]{false};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin.exceptions(cin.failbit);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> rounds[i].first >> rounds[i].second;
  }
  dp[t - 1][0] = canWin(rounds[t - 1].first, rounds[t - 1].second);
  dp[t - 1][1] = canLose(rounds[t - 1].first, rounds[t - 1].second);
  dp[t - 1][2] = !dp[t - 1][0];
  dp[t - 1][3] = !dp[t - 1][1];
  vector<bool> p(4);
  for (int i = t - 2; i >= 0; i--) {
    p[0] = canWin(rounds[i].first, rounds[i].second);
    p[1] = canLose(rounds[i].first, rounds[i].second);
    p[2] = !p[0];
    p[3] = !p[1];
    if (p[0]) {
      dp[i][0] = dp[i][0] || dp[i + 1][2];
      dp[i][1] = dp[i][1] || dp[i + 1][3];
    } else {
      dp[i][2] = dp[i][2] || dp[i + 1][2];
      dp[i][3] = dp[i][3] || dp[i + 1][3];
    }
    if (p[1]) {
      dp[i][0] = dp[i][0] || dp[i + 1][0];
      dp[i][1] = dp[i][1] || dp[i + 1][1];
    } else {
      dp[i][2] = dp[i][2] || dp[i + 1][0];
      dp[i][3] = dp[i][3] || dp[i + 1][1];
    }
  }
  cout << dp[0][0] << " " << dp[0][1] << "\n";
}
