#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> s(n);
  vector<long long int> e(n);
  for (long long int i = 0; i < n; i++) {
    cin >> s[i] >> e[i];
  }
  function<bool(long long int, long long int)> iswin = [&](long long int s,
                                                           long long int e) {
    if (e % 2 == 1) {
      if (s % 2 == 1) return true;
      return false;
    }
    if (s > (e / 2) && s <= e) {
      if (s % 2 == 1) return false;
      return true;
    }
    if (s <= (e / 2) && s > (e / 4)) {
      return false;
    }
    return iswin(s, e / 4);
  };
  function<bool(long long int, long long int)> islose = [&](long long int s,
                                                            long long int e) {
    if (s > (e / 2) && s <= e) {
      return false;
    }
    return iswin(s, e / 2);
  };
  bool winturn = true;
  for (long long int i = n - 1; i >= 0; i--) {
    if (winturn) {
      winturn = iswin(s[i], e[i]);
    } else {
      winturn = islose(s[i], e[i]);
    }
  }
  cout << (winturn ? 0 : 1) << " ";
  bool loseturn = false;
  for (long long int i = n - 1; i >= 0; i--) {
    if (loseturn) {
      loseturn = iswin(s[i], e[i]);
    } else {
      loseturn = islose(s[i], e[i]);
    }
  }
  cout << (loseturn ? 0 : 1) << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
