// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

#define rep(i,n) for(int i=0;i<n;i++)

vel solve(V<vel>& ab, int ex) {

	if (ex == 0) { return { 1, 0 }; }

	V<V<vel>> qab(2);

	for (vel x : ab) {

		int a1 = x[0];

		int b1 = x[1];

		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });

		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }

	}

	V<vel> c(3,vel(2));

	rep(i, 2) {

		for (auto x : qab[i]) {

			int qc = (3 - x[0] + x[1]) % 3; qc = (qc + 3) % 3;

			if (qc == 0) { c[i][0] ^= 1; }

			if (qc == 1) { c[i][1] ^= 1; }

			if (qc == 2) { c[i][0] ^= 1; c[i][1] ^= 1; }

		}

	}

	if (c[0] == c[2]) {

		vel ans = solve(qab[1], ex - 1);

		ans[0] *= 2; ans[1] *= 2;ans[1]++;

		return ans;

	}

	if (c[1] == c[2]) {

		vel ans = solve(qab[0], ex - 1);

		ans[0] *= 2; ans[1] *= 2;

		return ans;

	}

	rep(i, ab.size()) { ab[i][0]++; }

	vel ans = solve(ab, ex); ans[0]--;

	return ans;

}

signed main() {

	int inf = 2e17;

	int n; cin >> n;

	V<vel> ab(n);

	rep(i, n) {

		int a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	vel ret = solve(ab, 70);

	cout << ret[0] - inf << " " << ret[1] - inf << "\n";

}

// Faster C++ solution for the same problem (measured speedup: 1.1514133871863503x):
#include<iostream>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

#define rep(i,n) for(int i=0;i<n;i++)

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		int qc = 2 * x.first + x.second + 1;

	qc = (qc & (0xffffffff)) + ((qc & (0x7fffffff00000000)) >> 32);//qc<=1ffffffff

	qc = (qc & (0xffff)) + ((qc & (0x1ffff0000)) >> 16);//qc<=2ffff

	qc = (qc & (0xff)) + ((qc & (0x3ff00)) >> 8);//qc<=3ff

	qc = (qc & (0xf)) + ((qc & (0x3f0)) >> 4);//qc<=4e

	qc = (qc & (0xf)) + ((qc & (0x7e)) >> 4);//qc<=18

	qc = (qc & 3) + ((qc & 28) >> 2);

	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

      	qc = (qc & 3) + ((qc & 4) >> 2);

		c ^= qc;

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}