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

#define int long long
const ll N=2e5+55,inf=4e18;
array<ll,2>a[N],b[N];
ll n,m,k;

ll dst(ll i,ll j){
    ll LIK=((a[i][0]-b[j][0])*(a[i][0]-b[j][0])+(a[i][1]-b[j][1])*(a[i][1]-b[j][1]));
    assert(LIK<inf);
    if(LIK>=inf)exit(-1);
    return LIK;
}

ll chk(ll p1,ll p2){
    ll klk1=0,klk2=0;
    for(int d=0;d<k;++d){
        klk1=max(klk1,dst(p1+d,p2+d));
        klk2=max(klk2,dst(p1+d,p2+k-1-d));
    }
    return min({klk1,klk2});
}

vector<array<ll,2>>construct(ll p1,ll p2){
    ll klk1=0,klk2=0;
    for(int d=0;d<k;++d){
        klk1=max(klk1,dst(p1+d,p2+d));
        klk2=max(klk2,dst(p1+d,p2+k-1-d));
    }
    vector<array<ll,2>>ret;
    for(int d=0;d<k;++d){
        if(klk1<=klk2)ret.push_back({p1+d,p2+d});
        else ret.push_back({p1+d,p2+k-1-d});
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>m>>k;

    bool sub4=1;
    ll mn1=inf,mx1=0,mn2=inf,mx2=0;

    for(int i=1;i<=n;++i){
        cin>>a[i][0]>>a[i][1];
        if(a[i][1]!=a[1][1])sub4=0;
        mn1=min(mn1,a[i][1]);
        mx1=max(mx1,a[i][1]);
    }

    for(int i=1;i<=m;++i){
        cin>>b[i][0]>>b[i][1];
        if(b[i][1]!=b[1][1])sub4=0;
        mn2=min(mn2,b[i][1]);
        mx2=max(mx2,b[i][1]);
    }

    if(!(mn1>mx2||mn2>mx1))sub4=0;

    ll ans=inf;
    array<ll,2>dob={1,1};

    ll klk=chk(1,1);
    if(klk<ans){
        ans=klk;
        dob={1,1};
    }
    klk=chk(n-k+1,1);
    if(klk<ans){
        ans=klk;
        dob={n-k+1,1};
    }
    klk=chk(n-k+1,m-k+1);
    if(klk<ans){
        ans=klk;
        dob={n-k+1,m-k+1};
    }
    klk=chk(1,m-k+1);
    if(klk<ans){
        ans=klk;
        dob={1,m-k+1};
    }

    for(int i=1;i+k-1<=n&&!sub4;++i){
        ll l=1,r=m-k+1,gde=l,klk=inf;
        while(r-l>2){
            ll md1=l+(r-l)/3;
            ll md2=r-(r-l)/3;
            ll lef=chk(i,md1);
            ll rig=chk(i,md2);
            ll srd=chk(i,(md1+md2)/2);
            if(min({lef,rig,srd})==lef){
                if(lef<klk){
                    klk=lef;
                    gde=md1;
                }
                r=md1-1;
            }else if(min({lef,rig,srd})==srd){
                if(srd<klk){
                    klk=srd;
                    gde=(md1+md2)/2;
                }
                l=md1;
                r=md2;
            }else{
                if(rig<klk){
                    klk=rig;
                    gde=md2;
                }
                l=md2+1;
            }
        }
        for(int j=max(1ll,l-7);j<=min(m-k+1,r+7);++j){
            ll qu=chk(i,j);
            if(qu<klk){
                klk=qu;
                gde=j;
            }
        }
        if(klk<ans){
            ans=klk;
            dob={i,gde};
        }
    }

    cout<<ans<<'\n';
    vector<array<ll,2>>koji=construct(dob[0],dob[1]);
    for(auto[uu,vv]:koji)cout<<uu<<' '<<vv<<'\n';
}