#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
const int T = 1 << 17;
bool a[T], b[T];
bool win(ll s, ll e) {
  if (e & 1) return ~s & 1;
  if (e / 2 < s) return s & 1;
  if (e / 4 < s) return 1;
  return win(s, e / 4);
}
bool lose(ll s, ll e) {
  if (e / 2 < s) return 1;
  return win(s, e / 2);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  for (auto i = (0); i < (t); ++i) {
    ll s, e;
    cin >> s >> e;
    a[i] = win(s, e);
    b[i] = lose(s, e);
  }
  bool l = 1, w = 0;
  for (auto i = (0); i < (t); ++i) {
    if (l == w) break;
    if (w)
      w = !a[i], l = !b[i];
    else
      w = a[i], l = b[i];
  }
  cout << w << ' ' << l;
}
