#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

struct Kyuridenamida{
	vector<ll> dp;
	Kyuridenamida(int w):dp(w+1,0){
		dp[0]=1;
	}
	void Add(int w,int x){
		for(int i=int(dp.size())-1-w;i>=0;i--)
			add(dp[i+w],dp[i]*x);
	}
	void Del(int w,int x){
		for(int i=0;i+w<int(dp.size());i++)
			sub(dp[i+w],dp[i]*x);
	}
	void Sum(vi& s){
		FOR(i,1,dp.size())
			s[i]=dp[i]>0;
		FOR(i,1,s.size())
			s[i]+=s[i-1];
	}
	bool Hit(const vi& s,const int k){
		const auto get=[&](int i){
			int ret=0;
			i+=k;
			REP(tmp,2){
				int x=0;
				if(0<=i)
					x=i<int(s.size())?s[i]:s.back();
				if(tmp)
					ret-=x;
				else
					ret+=x;
				i=i-k-k-1;
			}
			return ret;
		};
		FOR(i,1,dp.size())
			if(dp[i]&&get(i))
				return true;
		return false;
	}
};

const int Yosupo=1;

struct Snuke{
	int m,c,t,r;
	Snuke(){
		r=rand()%Yosupo+1;
	}
	bool operator<(const Snuke& s)const{
		return c!=s.c?(c<s.c):(m<s.m);
	}
};

ostream& operator<<(ostream& os,Snuke s){
	os<<s.t<<" "<<s.m<<" "<<s.c;
	return os;
}

int main(){
	int na=read(),nb=read(),w=read();
	vector<Snuke> ss;
	REP(i,na){
		Snuke s;
		s.m=read();
		s.c=read();
		s.t=0;
		ss.PB(s);
	}
	REP(i,nb){
		Snuke s;
		s.m=read();
		s.c=read();
		s.t=1;
		ss.PB(s);
	}
	sort(ALL(ss));
	int l=-1,r=INT_MAX;
	REP(i,ss.size()-1)
		if(ss[i].t!=ss[i+1].t)
			chmin(r,max(abs(ss[i].m-ss[i+1].m),abs(ss[i].c-ss[i+1].c)));
	while(r-l>1){
		const int mid=(l+r)/2;
		int j=0;
		Kyuridenamida k[2]={Kyuridenamida(w),Kyuridenamida(w)};
		vi sum(w+1,0);
		bool ok=false;
		REP(i,ss.size()){
			k[ss[i].t].Add(ss[i].m,ss[i].r);
			while(ss[j].c<ss[i].c-mid){
				k[ss[j].t].Del(ss[j].m,ss[j].r);
				j++;
			}
			k[0].Sum(sum);
			if(k[1].Hit(sum,mid)){
				ok=true;
				break;
			}
		}
		if(ok)
			r=mid;
		else
			l=mid;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 3336