#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18,MOD=1e9+7;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back

void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}

template<typename T,typename V>
void PRINT(pair<T,V>& x){
    cerr<<"{";
    PRINT(x.fi);
    cerr<<",";
    PRINT(x.se);
    cerr<<"}";
}
template<typename T>
void PRINT(T &x){
    int id=0;
    cerr<<"{";
    for(auto _i:x){
        cerr<<(id++ ? "," : "");
        PRINT(_i);
    }
    cerr<<"}";
}
void _PRINT(){
    cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
    PRINT(h);
    if(sizeof...(t)) cerr<<", ";
    _PRINT(t...);
}

#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)

const int mxN=3001;
int N,M,K;
ll D[mxN+1][mxN+1];

ll Dist(pll a,pll b){
    return (a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se);
}

bool Subtask3(){
    return (N<=3000) && (M<=3000);
}

void Solve(){
    cin>>N>>M>>K;
    if(Subtask3()){
        multiset<ll> Ms[N+1][M+1];
        vector<pll> A(N+1),B(M+1);
        for(int i=1;i<=N;i++) cin>>A[i].fi>>A[i].se;
        for(int i=1;i<=M;i++) cin>>B[i].fi>>B[i].se;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=M;j++){
                D[i][j]=Dist(A[i],B[j]);
            }
        }
        ll res=LINF;
        int ir=-1,jr=-1;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=M;j++){
                Ms[i][j]=Ms[i-1][j-1]; Ms[i-1][j-1].clear();
                Ms[i][j].insert(D[i][j]);
                if(i-K>=0 && j-K>=0){
                    if(i-K>=1 && j-K>=1){
                        ll d=D[i-K][j-K];
                        Ms[i][j].erase(Ms[i][j].find(d));
                    }
                    ll tmp=*(prev(Ms[i][j].end()));
                    if(tmp<res){
                        ir=i,jr=j;
                        res=tmp;
                    }
                }
            }
        }
        cout<<res<<endl;
        ir-=K-1;
        jr-=K-1;
        for(int d=0;d<=K-1;d++){
            cout<<ir+d<<" "<<jr+d<<endl;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--){
        Solve();
    }
    return 0;
}