#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using vb = vector<bool>;
using vc = vector<char>;
using vd = vector<double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vlli = vector<lli>;
using vvlli = vector<vlli>;
using pi = pair<int, int>;
using plli = pair<lli, lli>;
int readint() {
  int q;
  scanf("%d", &q);
  return q;
}
lli readlong() {
  lli q;
  scanf("%lld", &q);
  return q;
}
double readdbl() {
  double q;
  scanf("%lf", &q);
  return q;
}
char readc() {
  char q;
  scanf("%c", &q);
  return q;
}
void printint(int q) { printf("%d", q); }
void printlong(lli q) { printf("%lld", q); }
void printdbl(double q, int p = 6) { printf("%.*lf", p, q); }
void readln() { scanf("\n"); }
void println() { printf("\n"); }
void space() { printf(" "); }
void print(int q) { printint(q); }
void print(lli q) { printlong(q); }
void print(double q) { printdbl(q); }
void print(char c) { printf("%c", c); }
template <typename T>
void println(T q) {
  print(q);
  println();
}
template <typename T>
void printsp(T q) {
  print(q);
  space();
}
template <typename T>
T maxim(T f, T s) {
  return (f > s) ? f : s;
}
template <typename T>
T minim(T f, T s) {
  return (f < s) ? f : s;
}
template <typename T>
T abs(T arg) {
  return arg < 0 ? -arg : arg;
}
const lli modulo = 1000000007;
bool win(lli x, lli e) {
  if (e & 1) return !(x & 1);
  if (x > e / 2) return (x & 1);
  if (x > e / 4) return true;
  return win(x, e / 4);
}
bool lose(lli x, lli e) {
  if (x > e / 2) return true;
  return win(x, e / 2);
}
int main() {
  int n = readint();
  vlli s(n), e(n);
  for (int i = 0; i < n; ++i) {
    s[i] = readlong();
    e[i] = readlong();
  }
  bool target = 1;
  for (int i = n - 1; i >= 0; i--) {
    bool firstwins = win(s[i], e[i]);
    bool firstloses = lose(s[i], e[i]);
    if (target) {
      if (firstwins)
        target = 0;
      else
        target = 1;
    } else {
      if (firstloses)
        target = 0;
      else
        target = 1;
    }
  }
  if (!target)
    printsp(1);
  else
    printsp(0);
  target = 0;
  for (int i = n - 1; i >= 0; i--) {
    bool firstwins = win(s[i], e[i]);
    bool firstloses = lose(s[i], e[i]);
    if (target) {
      if (firstwins)
        target = 0;
      else
        target = 1;
    } else {
      if (firstloses)
        target = 0;
      else
        target = 1;
    }
  }
  if (!target)
    printsp(1);
  else
    printsp(0);
  return 0;
}
