#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 110000;
int n, win[N], lose[N];
long long s[N], t[N];
inline int canLose(long long, long long);
inline int addMod(int a, int b) { return (a += b) >= mod ? a - mod : a; }
inline long long quickpow(long long base, long long pw) {
  long long ret = 1;
  while (pw) {
    if (pw & 1) ret = ret * base % mod;
    base = base * base % mod, pw >>= 1;
  }
  return ret;
}
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
  return;
}
inline int canWin(long long s, long long t) {
  long long lst = (t - 1) >> 1;
  if (s > lst) return ~(t - s) & 1;
  if (t & 1) return canLose(s, lst + 1);
  return canWin(s, lst + (lst & 1));
}
inline int canLose(long long s, long long t) {
  long long lst = (t - 1) >> 1;
  return s > lst || canWin(s, lst + 1);
}
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(s[i]), read(t[i]), ++t[i];
  win[n] = canWin(s[n], t[n]);
  lose[n] = canLose(s[n], t[n]);
  for (register int i = n - 1; i; --i) {
    int w = canWin(s[i], t[i]), l = canLose(s[i], t[i]);
    win[i] = (w && !win[i + 1]) || (l && win[i + 1]);
    lose[i] = (w && !lose[i + 1]) || (l && lose[i + 1]);
  }
  cout << win[1] << ' ' << lose[1] << endl;
  return 0;
}
