#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& stream, const vector<T> v) {
  stream << "[ ";
  for (int i = 0; i < (int)v.size(); i++) stream << v[i] << " ";
  stream << "]";
  return stream;
}
template <class T>
ostream& operator<<(ostream& stream, const pair<int, int> p) {
  stream << "(" << p.first << "," << p.second << ")";
  return stream;
}
long long fpow(long long x, long long p, long long m) {
  long long r = 1;
  for (; p; p >>= 1) {
    if (p & 1) r = r * x % m;
    x = x * x % m;
  }
  return r;
}
long long inv(long long a, long long b) {
  return a < 2 ? a : ((a - inv(b % a, a)) * b + 1) / a % b;
}
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long T, s[100010], e[100010], dp[2][100010][2], v[2][101][101];
int canfw(long long s, long long e) {
  if (e % 2)
    return (e - s) % 2;
  else {
    if (s > e / 2)
      return (e - s) % 2;
    else {
      if (s > e / 4) return 1;
      return canfw(s, e / 4);
    }
  }
}
int canfl(long long s, long long e) {
  if (2 * s > e) return 1;
  return canfw(s, e / 2);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  int i, j;
  for (i = 1; i <= T; i++) {
    cin >> s[i] >> e[i];
  }
  for (j = 1; j <= 100; j++)
    for (i = j; i > 0; i--) {
      if (i + 1 <= j) v[0][i][j] |= !v[0][i + 1][j];
      if (2 * i <= j) v[0][i][j] |= !v[0][2 * i][j];
      if (i + 1 > j)
        v[1][i][j] = 1;
      else
        v[1][i][j] |= !v[1][i + 1][j];
      if (2 * i > j)
        v[1][i][j] = 1;
      else
        v[1][i][j] |= !v[1][2 * i][j];
    }
  dp[0][T + 1][1] = 1;
  dp[1][T + 1][0] = 1;
  for (i = T; i > 0; i--) {
    for (int l = 0; l < 2; l++) {
      if (dp[l][i + 1][0] && dp[l][i + 1][1]) {
        dp[l][i][0] = dp[l][i][1] = 1;
      } else {
        int canfwin = canfw(s[i], e[i]), canflose = canfl(s[i], e[i]);
        if (dp[l][i + 1][1]) dp[l][i][0] = canfwin, dp[l][i][1] = !canfwin;
        if (dp[l][i + 1][0]) dp[l][i][0] = canflose, dp[l][i][1] = !canflose;
      }
    }
  }
  cout << dp[0][1][0] << " " << dp[1][1][0] << "\n";
  return 0;
}
