#include <bits/stdc++.h>
using namespace std;
int n, num, X[24 + 1], Y[24 + 1], dp[1 << 24 | 1], pre[1 << 24 | 1];
int ask(int i, int j) { return pow(X[i] - X[j], 2) + pow(Y[i] - Y[j], 2); }
int main() {
  scanf("%d%d%d", &X[0], &Y[0], &n);
  memset(dp, 0x3f, sizeof(dp));
  for (register int i = 1; i <= n; i = -~i) scanf("%d%d", &X[i], &Y[i]);
  dp[0] = 0;
  for (register int i = 0; i < (1 << n); i = -~i) {
    for (register int x = 1; x <= n; x = -~x) {
      if (i & (1 << (x - 1))) continue;
      for (register int y = 1; y <= n; y = -~y) {
        if (i & (1 << (y - 1))) continue;
        int dis = ask(0, x) + ask(x, y) + ask(y, 0) + dp[i];
        if (dp[i | (1 << (x - 1)) | (1 << (y - 1))] > dis) {
          pre[i | (1 << (x - 1)) | (1 << (y - 1))] = i;
          dp[i | (1 << (x - 1)) | (1 << (y - 1))] = dis;
        }
      }
      break;
    }
  }
  printf("%d\n", dp[num = (1 << n) - 1]);
  while (num) {
    int upd = num ^ pre[num];
    printf("0 ");
    for (register int i = 1; i <= n; i = -~i)
      if (upd & (1 << (i - 1))) printf("%d ", i);
    num = pre[num];
  }
  printf("0");
  return 0;
}
