Problem:
Score : 1000 points

Problem Statement

Red bold fonts show the difference from C1.

There is an infinitely large triangular grid, as shown below.
Each point with integer coordinates contains a lamp.

Initially, only the lamp at (X, Y) was on, and all other lamps were off.
Then, Snuke performed the following operation zero or more times:

Choose two integers x and y.
Toggle (on to off, off to on) the following three lamps: (x, y), (x, y+1), (x+1, y).

After the operations, N lamps (x_1, y_1), \cdots, (x_N, y_N) are on, and all other lamps are off.
Find X and Y.

Constraints

1 \leq N \leq 10^4

-10^{17} \leq x_i, y_i \leq 10^{17}

(x_i, y_i) are pairwise distinct.

The input is consistent with the statement, and you can uniquely determine X and Y.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print X and Y, separated by a space.

Sample Input 1

4
-2 1
-2 2
0 1
1 0

Sample Output 1

-1 0

The following picture shows one possible sequence of operations:

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#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;

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;
		ll d = x-x2;
		ll h = y2-y;
		if(d<0||d>h) continue;
		if((d&h)==d) ans^=1;
	}
	return ans;
}

ll rnd(ll x)
{
	ll ans=0;
	for(int i=0;i<5;i++)
	{
		ans<<=15; ans^=rand();
	}
	ans%=x;
	return ans;
}

ll rnd(ll l, ll r)
{
	return l+rnd(r-l+1);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		ll x,y; cin>>x>>y; vec.pb({x,y});
	}
	ll C = -((1LL<<61)-1);
	ll cur = 0;
	while(!color(cur,C))
	{
		C=rnd(-ll(3e17),-ll(3e18));
		int tmp=rnd(0,n-1);
		ll x=vec[tmp].fi; ll y=vec[tmp].se;
		ll h=y-C;
		for(int i=0;i<62;i++)
		{
			if(h&(1LL<<i))
			{
				if(rand()&1) x+=(1LL<<i);
			}
		}
		cur=x;
	}
	for(int i=61;i>=0;i--)
	{
		if(color(cur-(1LL<<i),C)) cur-=(1LL<<i);
	}
	ll l = cur;
	for(int i=61;i>=0;i--)
	{
		if(color(cur+(1LL<<i),C)) cur+=(1LL<<i);
	}
	ll r = cur;
	cout<<l<<' '<<C+(r-l)<<'\n';
}