#include <bits/stdc++.h>
using namespace std;
int T;
signed long long S[101010], E[101010];
int win[101010], lose[101010];
int canwin(signed long long s, signed long long e) {
  if (s == e) return 0;
  if (s >= e) return 1;
  if (e % 2) {
    return !(s % 2);
  } else {
    if (s * 2 > e) return (e - s) % 2;
    if (4 * s > e) return 1;
    return canwin(s, e / 4);
  }
}
int canlose(signed long long s, signed long long e) {
  if (e < 2 * s) return 1;
  return canwin(s, e / 2);
}
void solve() {
  int i, j, k, r, x, y;
  string s;
  cin >> T;
  for (i = 0; i < (T); i++) {
    cin >> S[i] >> E[i];
    win[i] = canwin(S[i], E[i]);
    lose[i] = canlose(S[i], E[i]);
  }
  int w = 1, l = 0;
  for (i = 0; i < (T); i++) {
    if (w == l) break;
    if (w) {
      w = lose[i];
      l = win[i];
    } else {
      w = !lose[i];
      l = !win[i];
    }
  }
  cout << l << " " << w << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
