#include <bits/stdc++.h>
bool win(long long s, long long e) {
  while (true) {
    if (e % 2 != 0)
      return (s % 2 == 0);
    else {
      e = e / 2;
      if (s > e) return (s % 2 != 0);
      e = e / 2;
      if (s > e) return true;
    }
  }
}
bool lose(long long s, long long e) {
  e = e / 2;
  if (s > e) return true;
  while (true) {
    if (e % 2 != 0)
      return (s % 2 == 0);
    else {
      e = e / 2;
      if (s > e) return (s % 2 != 0);
      e = e / 2;
      if (s > e) return true;
    }
  }
}
int main() {
  int n;
  long long s, e;
  bool fl1, fl2;
  bool zcount = false, flfind = false;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> s >> e;
    fl1 = win(s, e);
    fl2 = lose(s, e);
    if (fl1 && !fl2)
      zcount = (!zcount);
    else if (fl1 == fl2) {
      flfind = true;
      break;
    }
  }
  if (flfind) {
    if (zcount != fl1)
      std::cout << "1 1";
    else
      std::cout << "0 0";
  } else {
    if (zcount)
      std::cout << "1 0";
    else
      std::cout << "0 1";
  }
  return 0;
}
