#include <bits/stdc++.h>
using namespace std;
int64_t pw(int64_t b, int64_t p) {
  int64_t r = 1;
  while (p > 0) {
    if (p & 1) r = r * b;
    p = p >> 1;
    b = b * b;
  }
  return r;
}
const int64_t mx = ((int64_t)(1e6)) + ((int64_t)(1e6)) + 1;
bool win(int64_t s, int64_t e) {
  if (e & 1) {
    if (s & 1)
      return false;
    else
      return true;
  } else {
    if (e / 2 < s && s & 1)
      return true;
    else if (e / 2 < s)
      return false;
    else if (e / 4 < s)
      return true;
    else
      return win(s, e / 4);
  }
}
bool lose(int64_t s, int64_t e) {
  if (e < 2 * s)
    return true;
  else
    return win(s, e / 2);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t n;
  cin >> n;
  int64_t i;
  vector<pair<int64_t, int64_t> > pr(n);
  for (i = 0; i < n; ++i) {
    int64_t s, e;
    cin >> s >> e;
    pr[i] = {win(s, e), lose(s, e)};
  }
  int64_t w = 0, l = 1;
  for (i = 0; i < n; ++i) {
    if (w == 0 && l == 0) break;
    if (w == 1 && l == 1) break;
    if (w == 1) pr[i].first ^= 1, pr[i].second ^= 1;
    w = pr[i].first;
    l = pr[i].second;
  }
  cout << w << " " << l << endl;
  return 0;
}
