#include <bits/stdc++.h>
using namespace std;
bool win(long long s, long long e) {
  if (e % 2 == 1) {
    return s % 2 == 0;
  }
  if (s > e / 2) {
    return s % 2 == 1;
  }
  if (s > e / 4) return true;
  return win(s, e / 4);
}
bool lose(long long s, long long e) {
  if (s >= e / 2 + 1) {
    return true;
  }
  return win(s, e / 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  int nw = 0, nl = 0;
  vector<pair<long long, long long>> V(t);
  for (int i = 0; i < t; ++i) cin >> V[i].first >> V[i].second;
  reverse(V.begin(), V.end());
  bool w = win(V[0].first, V[0].second);
  bool l = lose(V[0].first, V[0].second);
  for (int i = 1; i < V.size(); ++i) {
    bool thisw = win(V[i].first, V[i].second);
    bool thisl = lose(V[i].first, V[i].second);
    if (w) {
      if (!thisl) w = false;
    } else {
      if (thisw) w = true;
    }
    if (l) {
      if (!thisl) l = false;
    } else {
      if (thisw) l = true;
    }
  }
  cout << w << ' ' << l;
  return 0;
}
