#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
int t;
long long s[N], e[N];
bool fst_win[N], fst_lose[N];
bool solve_win(long long st, long long x) {
  if (x & 1LL || st > x / 2) {
    return (x - st) % 2 == 1;
  }
  if (st > x / 4) {
    return true;
  }
  return solve_win(st, x / 4);
}
bool solve_lose(long long st, long long x) {
  if (st * 2 > x) {
    return true;
  }
  return solve_win(st, x / 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> s[i] >> e[i];
  }
  for (int i = 0; i < t; ++i) {
    fst_win[i] = solve_win(s[i], e[i]);
    fst_lose[i] = solve_lose(s[i], e[i]);
  }
  bool tryWin = true;
  bool tryLose = false;
  for (int i = t - 1; i > 0; --i) {
    if (tryWin) {
      tryWin = !fst_win[i];
    } else {
      tryWin = !fst_lose[i];
    }
    if (tryLose) {
      tryLose = !fst_win[i];
    } else {
      tryLose = !fst_lose[i];
    }
  }
  if ((tryWin && fst_win[0]) || (!tryWin && fst_lose[0])) {
    cout << 1 << ' ';
  } else {
    cout << 0 << ' ';
  }
  if ((tryLose && fst_win[0]) || (!tryLose && fst_lose[0])) {
    cout << 1 << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}
