#include<bits/stdc++.h>
using namespace std;
typedef long long li;
#define fi first
#define sc second
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
const int maxn = 2e5+5;
const li inf = 1e18;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m, k; cin >> n >> m >> k;
    vector<pii> a(n), b(m);
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        a[i] = {x, y};
    }
    for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        b[i] = {x, y};
    }

    sort(all(a), [&](pii l, pii r){
        if(l.fi != r.fi) return l.fi < r.fi;
        return l.sc < r.sc;
    });
    sort(all(b), [&](pii l, pii r){
        if(l.fi != r.fi) return l.fi < r.fi;
        return l.sc < r.sc;
    });

    auto dist = [&](int u, int v){
        return 1ll * (a[u].fi - b[v].fi)*(a[u].fi - b[v].fi) +  1ll * (a[u].sc - b[v].sc)*(a[u].sc - b[v].sc);
    };


    vector<int> mn(n);
    int sm = 0;
    for(int i = 0; i < n; i++){
        while(sm < m-1 && dist(i, sm) > dist(i, sm+1)){
            sm++;
        }
        mn[i] = sm;
    }


    if(k == 1){
        li MN = inf;
        int x;
        for(int i = 0; i < n; i++){
            if(dist(i, mn[i]) < MN){
                MN = dist(i, mn[i]);
                x = i;
            }
        }

        cout << dist(x, mn[x]) << '\n';
        cout << x+1 << ' ' << mn[x] + 1 << '\n';
    }
    return 0;
}