#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
long long a[100003], b[100003];
bool Getwin(long long x, long long y) {
  if (x > y) return 1;
  if (y & 1) return (x & 1) ^ 1;
  if (x == y) return 0;
  long long g = y >> 1, l = g + 1, r = y, type = 0;
  if (x >= l) return ((r - x) & 1) ^ type;
  while (1) {
    long long tg = g >> 1, tl = tg + 1, tr = g, tt;
    if (type == 2)
      tt = 0;
    else if (((r - tr * 2) & 1) ^ type)
      tt = (((r - tr) & 1) ^ type);
    else
      tt = 2;
    g = tg, l = tl, r = tr, type = tt;
    if (x >= l)
      if (type != 2)
        return ((r - x) & 1) ^ type;
      else
        return 1;
  }
}
bool Getlose(long long x, long long y) {
  if (x > y) return 0;
  if (x == y) return 1;
  long long g = y >> 1, l = g + 1, r = y, type = 2;
  if (x >= l) return 1;
  while (1) {
    long long tg = g >> 1, tl = tg + 1, tr = g, tt;
    if (type == 2)
      tt = 0;
    else if (((r - tr * 2) & 1) ^ type)
      tt = (((r - tr) & 1) ^ type);
    else
      tt = 2;
    g = tg, l = tl, r = tr, type = tt;
    if (x >= l)
      if (type != 2)
        return ((r - x) & 1) ^ type;
      else
        return 1;
  }
}
signed main() {
  long long n = read();
  for (long long i = 1; i <= n; ++i) a[i] = read(), b[i] = read();
  bool Fwin = 0, Flose = 0, Swin = 0, Slose = 0;
  for (long long i = n; i >= n; --i) {
    Fwin = Getwin(a[i], b[i]), Flose = Getlose(a[i], b[i]);
    Swin = Getwin(a[i] + 1, b[i]) && Getwin(a[i] << 1, b[i]),
    Slose = Getlose(a[i] + 1, b[i]) && Getlose(a[i] << 1, b[i]);
  }
  for (long long i = n - 1; i >= 1; --i) {
    bool fwin, flose, swin, slose;
    fwin = Getwin(a[i], b[i]), flose = Getlose(a[i], b[i]);
    swin = Getwin(a[i] + 1, b[i]) && Getwin(a[i] << 1, b[i]),
    slose = Getlose(a[i] + 1, b[i]) && Getlose(a[i] << 1, b[i]);
    bool tfw, tfl, tsw, tsl;
    tfw = (fwin && Swin) || (flose && Fwin) || (Fwin && Swin),
    tfl = (fwin && Slose) || (flose && Flose) || (Flose && Slose),
    tsw = (swin && Swin) || (slose && Fwin) || (Fwin && Swin),
    tsl = (swin && Slose) || (slose && Flose) || (Flose && Slose), Fwin = tfw,
    Flose = tfl, Swin = tsw, Slose = tsl;
  }
  printf("%d %d\n", (signed)Fwin, (signed)Flose);
  return 0;
}
