#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 5;
int t, n;
long long s[MX], e[MX];
bool w(long long s, long long e) {
  do {
    if (e & 1) return (s & 1) ^ 1;
    if (e / 2 < s && s <= e) return s & 1;
    if (e / 4 < s && s <= e / 2) return 1;
    e /= 4;
  } while (s <= e);
  return 1;
}
bool l(long long s, long long e) {
  if (e < 2 * s) return 1;
  return w(s, e / 2);
}
void solve() {
  cin >> t;
  for (int i = (0); i < (t); ++i) cin >> s[i] >> e[i];
  bool wf = 0, lf = 1;
  for (int i = (t)-1; i >= (0); --i) {
    bool wi, li;
    if (wf | lf) li = l(s[i], e[i]);
    if (!wf | !lf) wi = w(s[i], e[i]);
    wf = wf ? li : wi;
    lf = lf ? li : wi;
  }
  cout << wf << ' ' << lf << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
