#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;

vector<array<li,3>> a, b;

 li dist(int u, int v){
    return 1ll * (a[u][0] - b[v][0])*(a[u][0] - b[v][0]) +  1ll * (a[u][1] - b[v][1])*(a[u][1] - b[v][1]);
}



int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m, k; cin >> n >> m >> k;
    a = vector<array<li,3>>(n);
    b = vector<array<li,3>>(m);
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        a[i] = {x, y, i};
    }
    for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        b[i] = {x, y, i};
    }

    sort(all(a), [&](auto l, auto r){
        if(l[0] != r[0]) return l[0] < r[0];
        return l[1] < r[1];
    });
    sort(all(b), [&](auto l, auto r){
        if(l[0] != r[0]) return l[0] < r[0];
        return l[1] < r[1];
    });



    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 = -1;
        int x;
        for(int i = 0; i < n; i++){
            if(dist(i, mn[i]) < MN || MN == -1){
                MN = dist(i, mn[i]);
                x = i;
            }
        }

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