#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool win(ll s, ll e) {
  assert(s <= e);
  if (e % 2 || s > e / 2) {
    return s % 2 != e % 2;
  } else if (s > e / 4) {
    return true;
  } else {
    return win(s, e / 4);
  }
}
bool lose(ll s, ll e) {
  assert(s <= e);
  if (2 * s > e) {
    return true;
  }
  return win(s, e / 2);
}
const ll N = 1e6 + 10;
ll t;
ll s;
ll e;
bool first;
bool second;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  first = false;
  second = true;
  while (t--) {
    cin >> s >> e;
    bool w = win(s, e);
    bool l = lose(s, e);
    bool tx = (second && w) || (first && !w);
    bool ty = (second && l) || (first && !l);
    first = tx;
    second = ty;
  }
  cout << first << " " << second << "\n";
  return 0;
}
