#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
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);}
int L[N],R[N];
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;
void CalcInterval(ll k){
    for(int i=1;i<=n;i++){
        L[i]=m+10;R[i]=0;
        for(int j=1;j<=m;j++)if(Dist(a[i],b[j])<=k)R[i]=j;
        for(int j=m;j>=1;j--)if(Dist(a[i],b[j])<=k)L[i]=j;
        /*int l=1,r=m-1,o=0;
        while(l<=r){
            int mid=l+r>>1;
            if(Dist(a[i],b[mid])<=Dist(a[i],b[mid+1]))
        }*/
        //printf("%i: %i %i\n",i,L[i],R[i]);
    }
}
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;
    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;
        }
    }
    /*for(int j=L[IND];j<=R[IND];j++){
        if(L[IND+K-1]<=j+K-1&&j+K-1<=R[IND+K-1]){
            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>1100||m>1100)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);
    }
    /*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();
    printf("%lld\n",res);
    //vector<pair<int,int>>ans=Res;
    vector<pair<int,int>>ans=Construct(res,IND);
    if(REV)for(auto &[u,v]:ans)v=m+1-v;
    for(auto [u,v]:ans)printf("%i %i\n",u,v);
    return 0;
}