#include <bits/stdc++.h>
using namespace std;
int solve(long long r, int sign, long long loc) {
  long long l = r >> 1;
  if (loc > l) {
    return !((loc & 1) ^ sign);
  }
  if (sign) {
    r = l;
    l >>= 1;
    if (loc > l)
      return 1;
    else {
      return solve(l, !(l & 1), loc);
    }
  } else {
    return !(loc & 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> s(n), t(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  vector<vector<int>> win(2, vector<int>(n, 0));
  vector<vector<int>> lose(2, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    win[1][i] = solve(t[i], !(t[i] & 1), s[i]);
    if (s[i] > (t[i] >> 1)) {
      lose[1][i] = 1;
    } else
      lose[1][i] = solve((t[i] >> 1), !((t[i] >> 1) & 1), s[i]);
    win[0][i] = win[1][i] ^ 1;
    lose[0][i] = lose[1][i] ^ 1;
  }
  vector<vector<int>> dpw(2, vector<int>(n, 0)), dpl(2, vector<int>(n, 0));
  dpw[0][n - 1] = win[0][n - 1];
  dpw[1][n - 1] = win[1][n - 1];
  dpl[0][n - 1] = lose[0][n - 1];
  dpl[1][n - 1] = lose[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      if (dpw[0][i + 1]) {
        dpw[j][i] |= win[j][i];
      }
      if (dpw[1][i + 1]) {
        dpw[j][i] |= lose[j][i];
      }
      if (dpl[0][i + 1]) {
        dpl[j][i] |= win[j][i];
      }
      if (dpl[1][i + 1]) {
        dpl[j][i] |= lose[j][i];
      }
    }
  }
  cout << dpw[1][0] << ' ' << dpl[1][0] << '\n';
  return 0;
}
