#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int n, can_win[MAXN + 5], can_lose[MAXN + 5];
struct game {
  long long s, e;
} a[MAXN + 5];
bool get_win(long long s, long long e) {
  assert(s <= e);
  if (e % 2 == 1) {
    if (s % 2 == 1)
      return 0;
    else
      return 1;
  } else {
    if (s * 2 > e) {
      if (s % 2 == 1)
        return 1;
      else
        return 0;
    } else if (s * 4 > e) {
      return 1;
    } else {
      return get_win(s, e / 4);
    }
  }
}
bool get_lose(long long s, long long e) {
  if (s * 2 > e) {
    return 1;
  } else {
    return get_win(s, e / 2);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i].s >> a[i].e;
  can_lose[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (can_lose[i - 1] && can_win[i - 1]) {
      cout << 1 << " " << 1 << endl;
      return 0;
    }
    if (!can_lose[i - 1] && !can_win[i - 1]) {
      cout << 0 << " " << 0 << endl;
      return 0;
    }
    if (can_lose[i - 1]) {
      can_win[i] = get_win(a[i].s, a[i].e);
      can_lose[i] = get_lose(a[i].s, a[i].e);
    } else {
      can_win[i] = (!get_win(a[i].s, a[i].e));
      can_lose[i] = (!get_lose(a[i].s, a[i].e));
    }
  }
  cout << can_win[n] << " " << can_lose[n] << endl;
  return 0;
}
