#include <iostream> #include <cstring> #include <cstdio> #include <queue> #include <algorithm> #include <cmath> #include <vector> #include <map> using namespace std; #define inf 0x7fffffff #define ll long long #define mod (1000000007) #define maxn 200005 ll s[maxn],e[maxn]; ll win(ll s,ll e){ if(e&1){ if(s&1) return 0; return 1; } if(s>e/2){ if(s&1) return 1; return 0; } if(s>e/4) return 1; return win(s,e>>2); } ll lose(ll s,ll e){ if(s>e/2) return 1; return win(s,e>>1); } int main(){ ll i, n, j, k, t, m, w, l,cur=0; scanf("%lld",&t); for(i=1;i<=t;i++) scanf("%lld%lld",&s[i],&e[i]); for(i=1;i<=t;i++){ w=win(s[i],e[i]); l=lose(s[i],e[i]); w^=cur; l^=cur; if(w==l) break; if(w) cur=1; else cur=0; } printf("%lld %lld\n",w,l); }