#include <bits/stdc++.h>
using namespace std;
long long MOD(long long x, long long m) {
  long long r = x % m;
  if (r < 0) {
    r += m;
  }
  return r;
}
ostream& operator<<(ostream& str, const pair<long long, long long>& p) {
  str << p.first << " " << p.second;
  return str;
}
template <typename T>
void join(T& arr, string sep) {
  bool first = true;
  for (auto t : arr) {
    if (first) {
      first = false;
      cout << t;
    } else {
      cout << sep << t;
    }
  }
  cout << "\n";
}
void solve() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > se(n);
  for (long long i = 0; i < (long long)(n); ++i) {
    long long s, e;
    cin >> s >> e;
    se[i].first = s;
    se[i].second = e;
  }
  vector<pair<long long, long long> > dp1(n);
  vector<pair<long long, long long> > dp2(n);
  function<long long(long long, long long)> win = [&](long long s,
                                                      long long e) {
    if (((e)&1) == 1) {
      return ((s)&1) == 0 ? 1ll : 0ll;
    }
    if (2 * s > e) {
      return ((s)&1) == 1 ? 1ll : 0ll;
    }
    if (4 * s > e) {
      return 1ll;
    }
    return win(s, e / 4);
  };
  function<long long(long long, long long)> lose = [&](long long s,
                                                       long long e) {
    if (2 * s > e) {
      return 1ll;
    }
    return win(s, e / 2);
  };
  dp1.back().first = win(se.back().first, se.back().second);
  dp1.back().second = lose(se.back().first, se.back().second);
  dp2.back().first = !win(se.back().first, se.back().second);
  dp2.back().second = !lose(se.back().first, se.back().second);
  for (long long i = (long long)(n - 1) - 1; i >= (long long)(0); --i) {
    long long s = se[i].first;
    long long e = se[i].second;
    dp1[i].first =
        win(s, e) && dp2[i + 1].first || lose(s, e) && dp1[i + 1].first;
    dp1[i].second =
        win(s, e) && dp2[i + 1].second || lose(s, e) && dp1[i + 1].second;
    dp2[i].first =
        !win(s, e) && dp2[i + 1].first || !lose(s, e) && dp1[i + 1].first;
    dp2[i].second =
        !win(s, e) && dp2[i + 1].second || !lose(s, e) && dp1[i + 1].second;
  }
  cout << dp1[0] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  for (int t = 1; t <= tt; t++) {
    solve();
  }
  return 0;
}
