#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll C = -ll(1e18);

vector<ii> vec;

int color(ll x, ll y)
{
	int ans=0;
	int n=vec.size();
	for(int i=0;i<n;i++)
	{
		ll x2=vec[i].fi; ll y2=vec[i].se+C;
		ll d = x-x2;
		ll h = y2-y;
		if(d<0||d>h) continue;
		if((d&h)==d) ans^=1;
	}
	return ans;
}

int md[63];

ll getbelow(ll r, int mod)
{
	int res[3]; memset(res,0,sizeof(res));
	for(ii pt:vec)
	{
		ll x=pt.fi; ll y=pt.se;
		if(x>r) continue;
		ll mx = r-x;
		int dp[2][3];
		memset(dp,0,sizeof(dp));
		int xmod=x%3;
		if(xmod<0) xmod+=3;
		dp[1][0]=1;
		for(int i=62;i>=0;i--)
		{
			int nw[2][3]; memset(nw,0,sizeof(nw));
			for(int k=0;k<2;k++) //1 if still a prefix of mx
			{
				for(int l=0;l<3;l++) //mod
				{
					if(!dp[k][l]) continue;
					//add 1
					{
						if(y&(1LL<<i))
						{
							if(k==1&&!(mx&(1LL<<i)))
							{
								
							}
							else
							{
								int newk=0;
								if(k==1&&(mx&(1LL<<i))) newk=1;
								int newl=(l+md[i])%3;
								nw[newk][newl]^=1;
							}
						}
					}
					//add 0
					{
						int newk=0;
						if(k==1&&!(mx&(1LL<<i))) newk=1;
						int newl=l;
						nw[newk][newl]^=1;
					}
				}
			}
			for(int k=0;k<2;k++) //1 if still a prefix of mx
			{
				for(int l=0;l<3;l++) //mod
				{
					dp[k][l]=nw[k][l];
				}
			}
		}
		for(int l=0;l<3;l++)
		{
			int nwmod=(xmod+l)%3;
			int as=(dp[0][l]^dp[1][l]);
			//cerr<<"L "<<l<<' '<<as<<'\n';
			res[nwmod]^=as;
		}
	}
	return res[mod];
}

ll getcount(ll l, ll r, int mod) //%3 = mod
{
	return getbelow(r,mod)^getbelow(l-1,mod);
}

const int DEBUG=0;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	for(int i=0;i<63;i++) md[i]=((1LL<<i))%3;
	if(DEBUG)
	{
		ll x=rand(); ll y=rand();
		//cerr<<"ORI "<<x<<' '<<y<<'\n';
		set<ii> S; S.insert({x,y});
		for(int op=0;op<10;op++)
		{
			ll x=(*S.begin()).fi; ll y=(*S.begin()).se;
			S.erase({x,y});
			if(rand()&1)
			{
				if(S.find({x+1,y})==S.end()) S.insert({x+1,y});
				else S.erase({x+1,y});
				if(S.find({x,y+1})==S.end()) S.insert({x,y+1});
				else S.erase({x,y+1});
			}
			else
			{
				if(S.find({x-1,y})==S.end()) S.insert({x-1,y});
				else S.erase({x-1,y});
				if(S.find({x-1,y+1})==S.end()) S.insert({x-1,y+1});
				else S.erase({x-1,y+1});
			}
		}
		for(ii pr:S) vec.pb(pr);
	}
	else
	{
		int n; cin>>n;
		for(int i=0;i<n;i++)
		{
			ll x,y; cin>>x>>y; vec.pb({x,y});
		}
	}
	for(int i=0;i<vec.size();i++) vec[i].se-=C;
	int mod=-1;
	for(int i=0;i<3;i++)
	{
		//cerr<<getcount(-ll(2e18),ll(2e18),i)<<'\n';
		if(getcount(-ll(2e18),ll(2e18),i)){mod=i; break;}
	}
	assert(mod!=-1);
	ll lo=-ll(2e18); ll hi=ll(2e18);
	while(lo<hi)
	{
		ll mid=(lo+hi)>>1;
		if(getcount(lo,mid,mod))
		{
			hi=mid;
		}
		else
		{
			lo=mid+1;
		}
	}
	ll cur = lo;
	//cerr<<"MOD : "<<mod<<" | "<<cur<<' '<<getcount(cur,cur,mod)<<'\n';
	//assert(color(cur,C));
	for(int i=62;i>=0;i--)
	{
		if(color(cur-(1LL<<i),C)) cur-=(1LL<<i);
	}
	ll x = cur;
	for(int i=62;i>=0;i--)
	{
		if(color(cur+(1LL<<i),C)) cur+=(1LL<<i);
	}
	ll y = C+(cur-x);
	cout<<x<<' '<<y<<'\n';
}


Measured memory_bytes: 640