#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define mp make_pair
#define ld long double
#pragma GCC optimize("Ofast,unroll-loops")
const int N=2e5+50;
const ll INF=2e18+50;
int n,m,K;
pair<ll,ll>a[N],b[N];
ll Dist(pair<ll,ll>A,pair<ll,ll>B){return (A.fi-B.fi)*(A.fi-B.fi)+(A.se-B.se)*(A.se-B.se);}
struct BIT{
    ll T[2*N+10];
    void Update(int i,ll x){for(i+=N;i<=2*N+5;i+=i&-i)T[i]+=x;}
    ll Get(int i){ll x=0;for(i+=N;i>=1;i-=i&-i)x+=T[i];return x;}
    ll Get(int l,int r){return Get(r)-Get(l-1);}
    void Clear(){for(int i=0;i<=2*N+5;i++)T[i]=0;}
}bt[2];
int IND;bool REV;
int L[N],R[N],o[N];
void CalcO(){
    for(int i=1;i<=n;i++){
        int l=1,r=m;o[i]=1;
        while(l<r){
            int mid=l+r>>1;
            if(Dist(a[i],b[mid])<=Dist(a[i],b[mid+1]))r=mid,o[i]=mid;
            else l=mid+1,o[i]=mid+1;
        }
    }
}
void CalcInterval(ll k){
    /*for(int i=1;i<=n;i++){
        L[i]=m+1;R[i]=0;
        int l,r;
        l=1,r=o[i];
        while(l<=r){
            int mid=l+r>>1;
            if(Dist(a[i],b[mid])<=k)r=mid-1,L[i]=mid;
            else l=mid+1;
        }
        l=o[i],r=m;
        while(l<=r){
            int mid=l+r>>1;
            if(Dist(a[i],b[mid])<=k)l=mid+1,R[i]=mid;
            else r=mid-1;
        }
        //printf("%i: %i %i\n",i,L[i],R[i]);
    }*/
    for(int i=1,j=1;i<=n;i++){
        while(j<o[i]||(j<=m&&Dist(a[i],b[j])<=k))j++;
        R[i]=j-1;
    }
    for(int i=n,j=n;i>=1;i--){
        while(j>o[i]||(j>=1&&Dist(a[i],b[j])<=k))j--;
        L[i]=j+1;
    }
}
bool Check(ll k){
    CalcInterval(k);
    bt[0].Clear();
    bt[1].Clear();
    for(ll i=1,num0=0,num1=0;i<=n;i++){
        if(i>K){
            bt[0].Update(L[i-K]-(i-K),-1);
            bt[1].Update(R[i-K]-(i-K),-1);
            num0-=bt[0].Get(R[i-K]-(i-K)+1,N);
            num1-=bt[1].Get(L[i-K]-(i-K)-1);
            if(R[i-K]-(i-K)<L[i-K]-(i-K))num0--;
            if(L[i-K]-(i-K)>R[i-K]-(i-K))num1--;
        }
        num0+=bt[1].Get(L[i]-i-1);
        num1+=bt[0].Get(R[i]-i+1,N);
        if(R[i]-i<L[i]-i)num0++;
        if(L[i]-i>R[i]-i)num1++;
        bt[0].Update(L[i]-i,1);
        bt[1].Update(R[i]-i,1);
        if(i>=K&&num0==0&&num1==0){
            IND=i-K+1;
            return true;
        }
        /*if(i>=K){
            bool moze=true;
            for(int l=i-K+1;l<=i;l++)for(int r=l;r<=i;r++){
                if(R[l]-l<L[r]-r||L[l]-l>R[r]-r)moze=false;
            }
            if(moze){
                IND=i-K+1;
                return true;
            }
        }*/
    }
    return false;
}
vector<pair<int,int>>Construct(ll k,int ind=0){
    CalcInterval(k);
    if(ind==0){
        Check(k);
        ind=IND;
    }
    vector<pair<int,int>>res;
    //int pref[m+10]={0};
    vector<pair<int,int>>ev;
    for(int k=0;k<=K-1;k++){
        ev.pb({L[ind+k]-k,1});
        ev.pb({R[ind+k]-k+1,-1});
        //pref[max(L[ind+k]-k,1)]++;
        //pref[max(R[ind+k]-k+1,1)]--;
    }
    sort(ev.begin(),ev.end());
    for(int j=-m-5,k=0,sum=0;j<=m;j++){
        while(k<ev.size()&&ev[k].fi<=j)sum+=ev[k++].se;
        if(sum==K){
            for(int k=0;k<=K-1;k++){
                res.pb({ind+k,j+k});
            }
            break;
        }
    }
    /*for(int j=1;j+K-1<=m;j++){
        bool moze=true;
        for(int k=0;k<=K-1;k++){
            if(!(L[ind+k]<=j+k&&j+k<=R[ind+k]))moze=false;
        }
        if(moze){
            for(int k=0;k<=K-1;k++){
                res.pb({ind+k,j+k});
            }
            break;
        }
    }*/
    return res;
}

/*vector<pair<int,int>>Res;
ll Brute(){
    ll res=INF;
    int I=0,J=0;
    for(int i=1;i+K-1<=n;i++){
        for(int j=1;j+K-1<=m;j++){
            ll mn=0;
            for(int k=0;k<=K-1;k++){
                mn=max(mn,Dist(a[i+k],b[j+k]));
            }
            if(mn<res){
                res=mn;
                IND=i;
                I=i,J=j;
            }
        }
    }
    for(int k=0;k<=K-1;k++)Res.pb({I+k,J+k});
    return res;
}*/
int main(){
    scanf("%i%i%i",&n,&m,&K);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i].fi,&a[i].se);
    for(int i=1;i<=m;i++)scanf("%lld%lld",&b[i].fi,&b[i].se);
    //if(n>3100||m>3100)exit(-1);
    if(n>1&&m>1){
        if(a[1].fi!=a[n].fi){
            if((a[n].fi>a[1].fi)!=(b[m].fi>b[1].fi))REV=true;
        }
        if(a[1].se!=a[n].se){
            if((a[n].se>a[1].se)!=(b[m].se>b[1].se))REV=true;
        }
    }
    if(REV){
        reverse(b+1,b+m+1);
    }
    CalcO();
    if(K==1){
        ll res=INF;int ind=0;
        for(int i=1;i<=n;i++)if(res>Dist(a[i],b[o[i]])){
            res=Dist(a[i],b[o[i]]);
            ind=i;
        }
        vector<pair<int,int>>ans={{ind,o[ind]}};
        if(REV)for(auto &[u,v]:ans)v=m+1-v;
        printf("%lld\n",res);
        for(auto [u,v]:ans)printf("%i %i\n",u,v);
        return 0;
    }
    ll l=0,r=INF,res=INF;
    while(l<=r){
        ll mid=l+(r-l>>1);
        if(Check(mid))res=mid,r=mid-1;
        else l=mid+1;
    }
    //ll res=Brute();
    //vector<pair<int,int>>ans=Res;
    vector<pair<int,int>>ans=Construct(res);
    if(REV)for(auto &[u,v]:ans)v=m+1-v;
    printf("%lld\n",res);
    for(auto [u,v]:ans)printf("%i %i\n",u,v);
    return 0;
}