//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}
template<size_t maxn>
struct Sat
{
    vector<int> edge[2*maxn],re[2*maxn];
    int n;
    void init(int _n)
    {
        n=_n;
        for(int i=0;i<2*n;i++) edge[i].clear(),re[i].clear();
    }
    void add(int p,bool x,int q,bool y)
    {
        //0base
        int u=p<<1|(!x),v=q<<1|(!y);
        edge[u].push_back(v);edge[v^1].push_back(u^1);
        re[v].push_back(u);re[u^1].push_back(v^1);
    }
    bitset<2*maxn> vis;
    void dfs1(int u,vector<int> &r)
    {
        vis[u]=1;
        for(auto v:edge[u]) if(!vis[v])
            dfs1(v,r);
        r.push_back(u);
    }
    bitset<2*maxn> ans;
    //int id[2*maxn];
    void dfs2(int u,vector<int> &r)
    {
        vis[u]=1;//id[u]=p;
        for(auto v:re[u]) if(!vis[v])
            dfs2(v,r);
        r.push_back(u);
    }
#if 0
    void zet(int u,bool x)
    {
        vis[u]=1;ans[u]=x;
        for(auto v:re[u]) if(!vis[v] && id[v]==id[u])
            zet(v,x);
    }
#endif
    bool ask(int p){return ans[p<<1];}
    void visreset()
    {
        if(n>=(int)maxn/16) vis.reset();
        else for(int i=0;i<2*n;i++) vis[i]=0;
    }
    bool sol()
    {
        vector<int> ret;visreset();
        for(int i=0;i<2*n;i++) if(!vis[i])
            dfs1(i,ret);
        reverse(ret.begin(),ret.end());
        vector<int> nret;visreset();
        for(auto u:ret) if(!vis[u])
            dfs2(u,nret);

        visreset();
        for(int u:nret) if(!vis[u])
        {
            vis[u]=1;vis[u^1]=1;
            ans[u]=0;ans[u^1]=1;
        }
        for(int i=0;i<2*n;i++) for(int j:edge[i])
        {
            if(ans[i] && !ans[j])
                return false;
        }
        return true;
    }
};
const int maxn=1e4+4;
int n,p[maxn][2];
void read()
{
    RI(n);
    REP1(i,1,n) RI(p[i][0],p[i][1]);
}
vector<pii> odr;
int rnk[maxn][2];
void build()
{
    REP1(i,1,n) REP(j,2) odr.pb({i,j});
    sort(ALL(odr),[&](pii a,pii b){return tie(p[a.F][a.S],a) < tie(p[b.F][b.S],b);});
    REP(i,SZ(odr)) rnk[odr[i].F][odr[i].S]=i;
}
Sat<4*(2*maxn)> sat;
struct Seg
{
    int dat[(2*maxn)<<2];
    int leaf[2*maxn];
#define Mid int mid=(low+high)/2
#define lc x<<1,low,mid
#define rc x<<1|1,mid+1,high
#define me x
    void init(int x,int low,int high)
    {
        if(low==high)
        {
            leaf[low]=x;
            return;
        }
        Mid;init(lc);init(rc);
        sat.add(x,0,x<<1,0);
        sat.add(x,0,x<<1|1,0);
    }
    void add(int x,int low,int high,int a,int b,int v)
    {
        if(low==a && b==high)
        {
            sat.add(v,1,x,0);
            return;
        }
        Mid;
        if(b<=mid) add(lc,a,b,v);
        else if(mid+1<=a) add(rc,a,b,v);
        else add(lc,a,mid,v),add(rc,mid+1,b,v);
    }
} seg;
bool test(int d)
{
    assert(d>0);
    sat.init(4*SZ(odr));
    seg.init(1,0,SZ(odr)-1);
    
    REP1(i,1,n)
    {
        sat.add(seg.leaf[rnk[i][0]],0,seg.leaf[rnk[i][1]],1);
        sat.add(seg.leaf[rnk[i][0]],1,seg.leaf[rnk[i][1]],0);
    }
    REP1(i,1,n) REP(j,2) 
    {
        int l=rnk[i][j]+1,r=lower_bound(ALL(odr),p[i][j]+d,[&](pii t,int x){return p[t.F][t.S]<x;})-odr.begin()-1;
        if(l>r) continue;
        seg.add(1,0,SZ(odr)-1,l,r,seg.leaf[rnk[i][j]]);
    }

    return sat.sol();
}
void sol()
{
    int l=0,r=1e9;
    while(r>l)
    {
        int mid=(l+r+1)/2;
        if(test(mid)) l=mid;
        else r=mid-1;
    }
    PL(l);
}
int main()
{
    read();
    build();
    sol();
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 29460