import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class CF8C {
	static int n;
	static int[] mem;
	static HashMap<Integer, String> map;
	static int INF = (int) 1e9;
	static StringBuilder sb;

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		String s = sc.nextLine();
		n = sc.nextInt();
		mem = new int[1 << n];
		Arrays.fill(mem, -1);
		map = new HashMap<>();
		map.put(0, s);
		for (int i = 1; i <= n; i++) {
			map.put(i, sc.nextLine());
		}
		int val = dp(0);
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(val);
		sb = new StringBuilder();
		sb.append("0 ");
		build(0);
		pw.println(sb);
		pw.flush();
	}

	// node == 0 -- > count 0 // state == 0 has 1 // state == 1 has 2

	private static int dp(int msk) {
		if (msk == (1 << n) - 1)
			return 0;

		if(mem[msk] != -1)
			return mem[msk];

		boolean foundFirst = false;
		int val = (int)1e9; 
		int mark = -1;
		for (int i = 1; i <= n; i++) {
			if ((msk & 1 << (i - 1)) == 0){
				if(!foundFirst){
					foundFirst = true;
					mark = i;
					val = dist(0, mark)*2 + dp(msk | 1 << (mark - 1));
				}else{
					val = Math.min(val, dist(0, mark) + dist(mark, i) + dist(i, 0) + dp((msk|1 << (mark - 1))|1 << (i - 1)));
				}
			}
		}
		return mem[msk] = val;
	}

	private static int dist(int node, int i) {
		String from = map.get(i);
		String to = map.get(node);
		String[] fromco = from.split(" ");
		String[] toco = to.split(" ");
		int xs = Integer.parseInt(fromco[0]);
		int ys = Integer.parseInt(fromco[1]);
		int xf = Integer.parseInt(toco[0]);
		int yf = Integer.parseInt(toco[1]);
		return (xs - xf) * (xs - xf) + (ys - yf) * (ys - yf);
	}

	private static void build(int msk) {
		if (msk == (1 << n) - 1) 
			return;
		boolean... What is the time complexity of the previous code?