#include <bits/stdc++.h>
using namespace std;
int xs, ys, n, dp[1<<24], d[25][25];
array<int, 2> a[24];
int sq(int x){return x*x;}
int BaoThy(int mask)
{
if(__builtin_popcount(mask)==n) return dp[mask]=0;
if(dp[mask]!=-1) return dp[mask];
int res=2e9;
for (int i=0; i<n; i++){
if(mask&(1<<i)) continue;
res=min(res, BaoThy(mask|(1<<i))+2*d[0][i+1]);
for (int j=i+1; j<n; j++){
if(mask&(1<<j)) continue;
res=min(res, BaoThy(mask|(1<<i)|(1<<j))+d[0][i+1]+d[i+1][j+1]+d[j+1][0]);
}
}
return dp[mask]=res;
}
void trace(int mask)
{
if(__builtin_popcount(mask)==n) return;
int res=dp[mask];
for (int i=0; i<n; i++){
if(mask&(1<<i)) continue;
if(res==dp[mask|(1<<i)]+2*d[0][i+1]){
cout << i+1 << " " << 0 << " ";
trace(mask|(1<<i));
return;
}
for (int j=i+1; j<n; j++){
if(mask&(1<<j)) continue;
if(res==dp[mask|(1<<i)|(1<<j)]+d[0][i+1]+d[i+1][j+1]+d[j+1][0]){
cout << i+1 << " " << j+1 << " " << 0 << " ";
trace(mask|(1<<i)|(1<<j));
return;
}
}
}
assert(0);
}
void solve()
{
memset(dp, -1, sizeof(dp));
int res=BaoThy(0);
cout << res << "\n" << 0 << " ";
trace(0);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen("LFO.inp", "r", stdin);
//freopen("LFO.out", "w", stdout);
cin >> xs >> ys >> n;
for (int i=0; i<n; i++){
cin >> a[i][0] >> a[i][1];
int t=sq(a[i][0]-xs)+sq(a[i][1]-ys);
d[i+1][0]=t;
d[0][i+1]=t;
}
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
int t=sq(a[j][0]-a[i][0])+sq(a[j][1]-a[i][1]);
d[i+1][j+1]=t;
d[j+1][i+1]=t;
}
}
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgeHMsIHlzLCBuLCBkcFsxPDwyNF0sIGRbMjVdWzI1XTsKYXJyYXk8aW50LCAyPiBhWzI0XTsKCmludCBzcShpbnQgeCl7cmV0dXJuIHgqeDt9CgppbnQgQmFvVGh5KGludCBtYXNrKQp7CiAgICBpZihfX2J1aWx0aW5fcG9wY291bnQobWFzayk9PW4pIHJldHVybiBkcFttYXNrXT0wOwogICAgaWYoZHBbbWFza10hPS0xKSByZXR1cm4gZHBbbWFza107CiAgICBpbnQgcmVzPTJlOTsKICAgIGZvciAoaW50IGk9MDsgaTxuOyBpKyspewogICAgICAgIGlmKG1hc2smKDE8PGkpKSBjb250aW51ZTsKICAgICAgICByZXM9bWluKHJlcywgQmFvVGh5KG1hc2t8KDE8PGkpKSsyKmRbMF1baSsxXSk7CiAgICAgICAgZm9yIChpbnQgaj1pKzE7IGo8bjsgaisrKXsKICAgICAgICAgICAgaWYobWFzayYoMTw8aikpIGNvbnRpbnVlOwogICAgICAgICAgICByZXM9bWluKHJlcywgQmFvVGh5KG1hc2t8KDE8PGkpfCgxPDxqKSkrZFswXVtpKzFdK2RbaSsxXVtqKzFdK2RbaisxXVswXSk7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIGRwW21hc2tdPXJlczsKfQoKdm9pZCB0cmFjZShpbnQgbWFzaykKewogICAgaWYoX19idWlsdGluX3BvcGNvdW50KG1hc2spPT1uKSByZXR1cm47CiAgICBpbnQgcmVzPWRwW21hc2tdOwogICAgZm9yIChpbnQgaT0wOyBpPG47IGkrKyl7CiAgICAgICAgaWYobWFzayYoMTw8aSkpIGNvbnRpbnVlOwogICAgICAgIGlmKHJlcz09ZHBbbWFza3woMTw8aSldKzIqZFswXVtpKzFdKXsKICAgICAgICAgICAgY291dCA8PCBpKzEgPDwgIiAiIDw8IDAgPDwgIiAiOwogICAgICAgICAgICB0cmFjZShtYXNrfCgxPDxpKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZm9yIChpbnQgaj1pKzE7IGo8bjsgaisrKXsKICAgICAgICAgICAgaWYobWFzayYoMTw8aikpIGNvbnRpbnVlOwogICAgICAgICAgICBpZihyZXM9PWRwW21hc2t8KDE8PGkpfCgxPDxqKV0rZFswXVtpKzFdK2RbaSsxXVtqKzFdK2RbaisxXVswXSl7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGkrMSA8PCAiICIgPDwgaisxIDw8ICIgIiA8PCAwIDw8ICAiICI7CiAgICAgICAgICAgICAgICB0cmFjZShtYXNrfCgxPDxpKXwoMTw8aikpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgYXNzZXJ0KDApOwp9Cgp2b2lkIHNvbHZlKCkKewogICAgbWVtc2V0KGRwLCAtMSwgc2l6ZW9mKGRwKSk7CiAgICBpbnQgcmVzPUJhb1RoeSgwKTsKICAgIGNvdXQgPDwgcmVzIDw8ICJcbiIgPDwgMCA8PCAiICI7CiAgICB0cmFjZSgwKTsKfQoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsgY291dC50aWUoMCk7CiAgICBmcmVvcGVuKCJMRk8uaW5wIiwgInIiLCBzdGRpbik7CiAgICAvL2ZyZW9wZW4oIkxGTy5vdXQiLCAidyIsIHN0ZG91dCk7CiAgICBjaW4gPj4geHMgPj4geXMgPj4gbjsKICAgIGZvciAoaW50IGk9MDsgaTxuOyBpKyspewogICAgICAgIGNpbiA+PiBhW2ldWzBdID4+IGFbaV1bMV07CiAgICAgICAgaW50IHQ9c3EoYVtpXVswXS14cykrc3EoYVtpXVsxXS15cyk7CiAgICAgICAgZFtpKzFdWzBdPXQ7CiAgICAgICAgZFswXVtpKzFdPXQ7CiAgICB9CiAgICBmb3IgKGludCBpPTA7IGk8bjsgaSsrKXsKICAgICAgICBmb3IgKGludCBqPWkrMTsgajxuOyBqKyspewogICAgICAgICAgICBpbnQgdD1zcShhW2pdWzBdLWFbaV1bMF0pK3NxKGFbal1bMV0tYVtpXVsxXSk7CiAgICAgICAgICAgIGRbaSsxXVtqKzFdPXQ7CiAgICAgICAgICAgIGRbaisxXVtpKzFdPXQ7CiAgICAgICAgfQogICAgfQogICAgc29sdmUoKTsKICAgIHJldHVybiAwOwp9Cg==