#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
long long aa[N], bb[N];
int test(long long a, long long b, int x, int e) {
  return e == 0 ? 1 : b - a & 1 ^ x;
}
int solve(long long a, long long b, int x, int e) {
  while (true) {
    if (a == b) return x;
    long long b_ = b / 2;
    if (a > b_) return test(a, b, x, e);
    int x1 = test(b_ + 1, b, x, e);
    int x2 = test(b_ * 2, b, x, e);
    x = x1 & x2 ^ 1;
    e = x2;
    b = b_;
  }
}
int can_win(long long a, long long b) { return solve(a, b, 0, 1); }
int can_lose(long long a, long long b) { return solve(a, b, 1, 0); }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> aa[i] >> bb[i];
  long long a = aa[n - 1], b = bb[n - 1];
  int w_ = can_win(a, b);
  int l_ = can_lose(a, b);
  for (int i = n - 2; i >= 0; i--) {
    a = aa[i], b = bb[i];
    int w = can_win(a, b);
    int l = can_lose(a, b);
    int w2 = l & w_ | w & (w_ ^ 1);
    int l2 = l & l_ | w & (l_ ^ 1);
    w_ = w2;
    l_ = l2;
  }
  cout << w_ << ' ' << l_ << '\n';
  return 0;
}
