#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
struct P { ll x,y; P() {} P(ll x,ll y):x(x),y(y) {} };

int n;
P p[MAXN];

ll qy;

int cntbits(ll dy) { int bits=0; while(dy>0) bits+=dy&1,dy>>=1; return bits; }

ll calcdesc(ll dy) { return 1LL<<cntbits(dy);  }

int calcpar(P a,ll mx) {
	int ret=0;
	ll dy=a.y-qy;
	int step=0; while((2LL<<step)<=dy) ++step;
	int bits=cntbits(dy);
	ll cx=a.x;
	while(true) {
		if(dy==0) { if(cx<=mx) ret^=1; break; }
		while(((dy>>step)&1)==0) --step;
		//printf("dy=%lld step=%d\n",dy,step);
		dy-=1LL<<step; --bits;
		if(cx+dy<=mx) { if(bits==0) ret^=1; cx+=1LL<<step; }
	}
	//printf("(%lld,%lld) mx=%lld -> %d\n",a.x,a.y,mx,ret);
	return ret;
}


int calcpar(ll mx) {
	int ret=0; REP(i,n) ret^=calcpar(p[i],mx); return ret;
}

pair<ll,ll> solve() {
	ll lx,hx,ly=LLONG_MAX; REP(i,n) ly=min(ly,p[i].y);

	/*REP(rep,16) {
		qy=ly-rep; lx=LLONG_MAX,hx=LLONG_MIN; REP(i,n) lx=min(lx,p[i].x),hx=max(hx,p[i].x+p[i].y-qy);
		printf("%3lld: ",qy); for(ll x=lx;x<=hx;++x) printf(" %d",calcpar(x)); puts("");
	}*/

	lx=LLONG_MAX,hx=LLONG_MIN; REP(i,n) lx=min(lx,p[i].x),hx=max(hx,p[i].x+p[i].y-ly);
	ll dx=hx-lx+1; while((dx&-dx)!=dx) dx+=dx&-dx; qy=-dx; assert(qy<=ly);
	//printf("ly=%lld lx=%lld hx=%lld dx=%lld qy=%lld\n",ly,lx,hx,dx,qy);

	assert(calcpar(lx+dx-1)==1);
	ll lft,rgt;
	{ ll lo=lx-1,hi=lx+dx-1; while(lo+1<hi) { ll mi=lo+(hi-lo)/2; if(calcpar(mi)==1) hi=mi; else lo=mi; } lft=hi; }
	//{ ll lo=lx+dx-1,hi=hx+dx+1; while(lo+1<hi) { ll mi=lo+(hi-lo)/2; if(calcsum(mi,2)==1) lo=mi; else hi=mi; } rgt=lo; }

	//printf("lft=%lld rgt=%lld\n",lft,rgt);
	ll ansx=lft,ansy=qy+(rgt-lft+1);

	return MP(ansx,0);
}


void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%lld%lld",&p[i].x,&p[i].y);
	printf("%lld\n",solve().first);
}

void stress() {
	int rng=21,sub=10;
	REP(rep,100000) {
		set<pair<int,int>> cur;
		pair<int,int> want=MP(rand()%rng-sub,0);
		cur.insert(want);
		int nops=rand()%1; REP(i,nops) { int x=rand()%rng-sub,y=rand()%rng-sub; REP(j,3) { int cx=x+(j==1?1:0),cy=y+(j==2?1:0); if(cur.count(MP(cx,cy))) cur.erase(MP(cx,cy)); else cur.insert(MP(cx,cy)); } }
		n=0; for(auto it=cur.begin();it!=cur.end();++it) p[n].x=it->first,p[n].y=it->second,++n;
		pair<ll,ll> have=solve();
		if(have.first==want.first&&have.second==want.second) { printf("."); continue; }
		printf("err\n");
		printf("have=(%lld,%lld) want=(%d,%d)\n",have.first,have.second,want.first,want.second);
		exit(0);
	}
}

int main() {
	run();
	//stress();
	return 0;
}


Measured memory_bytes: 1792