import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

import static java.lang.Math.*;

// Solution is at the bottom of code

public class ProblemC_008 implements Runnable{

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	OutputWriter out;
	StringTokenizer tok = new StringTokenizer("");

	public static void main(String[] args){
		new Thread(null, new ProblemC_008(), "", 128 * (1L << 20)).start();
	}

	/////////////////////////////////////////////////////////////////////

	void init() throws FileNotFoundException{
		Locale.setDefault(Locale.US);

		if (ONLINE_JUDGE){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new OutputWriter(System.out);
		}else{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new OutputWriter("output.txt");
		}
	}

	////////////////////////////////////////////////////////////////

	long timeBegin, timeEnd;

	void time(){
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}

	void debug(Object... objects){
		if (ONLINE_JUDGE){
			for (Object o: objects){
				System.err.println(o.toString());
			}
		}
	}

	/////////////////////////////////////////////////////////////////////

	public void run(){
		try{
			timeBegin = System.currentTimeMillis();
			Locale.setDefault(Locale.US);

			init();
			solve();

			out.close();
			time();
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	/////////////////////////////////////////////////////////////////////

	String delim = " ";

	String readString() throws IOException{
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(in.readLine());
			}catch (Exception e){
				return null;
			}
		}

		return tok.nextToken(delim);
	}

	String readLine() throws IOException{
		return in.readLine();
	}

	/////////////////////////////////////////////////////////////////

	final char NOT_A_SYMBOL = '\0';

	char readChar() throws IOException{
		int intValue = in.read();

		if (intValue == -1){
			return NOT_A_SYMBOL;
		}

		return (char) intValue;
	}

	char[] readCharArray() throws IOException{
		return readLine().toCharArray();
	}

	/////////////////////////////////////////////////////////////////

	int readInt() throws IOException{
		return Integer.parseInt(readString());
	}

	int[] readIntArray(int size) throws IOException{
		int[] array = new int[size];

		for (int index = 0; index < size; ++index){
			array[index] = readInt();
		}

		return array;
	}

	///////////////////////////////////////////////////////////////////

	long readLong() throws IOException{
		return Long.parseLong(readString());
	}

	long[] readLongArray(int size) throws IOException{
		long[] array = new long[size];

		for (int index = 0; index < size; ++index){
			array[index] = readLong();
		}

		return array;
	}

	////////////////////////////////////////////////////////////////////

	double readDouble() throws IOException{
		return Double.parseDouble(readString());
	}

	double[] readDoubleArray(int size) throws IOException{
		double[] array = new double[size];

		for (int index = 0; index < size; ++index){
			array[index] = readDouble();
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	Point readPoint() throws IOException{
		return new Point(readInt(), readInt());
	}

	Point[] readPointArray(int size) throws IOException{
		Point[] array = new Point[size];

		for (int index = 0; index < size; ++index){
			array[index] = readPoint();
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	class OutputWriter extends PrintWriter{

		final int DEFAULT_PRECISION = 12;

		int precision;
		String format, formatWithSpace;

		{
			precision = DEFAULT_PRECISION;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		public OutputWriter(OutputStream out) {
			super(out);
		}

		public OutputWriter(String fileName) throws FileNotFoundException {
			super(fileName);
		}

		public int getPrecision() {
			return precision;
		}

		public void setPrecision(int precision) {
			this.precision = precision;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		private String createFormat(int precision){
			return "%." + precision + "f";
		}

		@Override
		public void print(double d){
			printf(format, d);
		}

		public void printWithSpace(double d){
			printf(formatWithSpace, d);
		}

		public void printAll(double...d){
			for (int i = 0; i < d.length - 1; ++i){
				printWithSpace(d[i]);
			}

			print(d[d.length - 1]);
		}

		@Override
		public void println(double d){
			printlnAll(d);
		}

		public void printlnAll(double... d){
			printAll(d);
			println();
		}
	}

	/////////////////////////////////////////////////////////////////////

	int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

	boolean check(int index, int lim){
		return (0 <= index && index < lim);
	}

	/////////////////////////////////////////////////////////////////////

	void solve() throws IOException{
		Point bag = readPoint();

		int n = readInt();

		Point[] points = new Point[n];

		for (int i = 0; i < n; ++i){
			points[i] = readPoint();
		}

		int[] dist = new int[n];
		for (int i = 0; i < n; ++i){
			int dx = points[i].x - bag.x;
			int dy = points[i].y - bag.y;

			dist[i] = dx * dx + dy * dy;
		}

		int[][] d = new int[n][n];
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < n; ++j){
				int dx = points[i].x - points[j].x;
				int dy = points[i].y - points[j].y;

				d[i][j] = dx * dx + dy * dy;
				d[i][j] += dist[i] + dist[j];
			}
		}

		int[] singleMasks = new int[n];
		for (int i = 0; i < n; ++i){
			singleMasks[i] = (1 << i);
		}

		int[][] doubleMasks = new int[n][n];
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < n; ++j){
				doubleMasks[i][j] = (singleMasks[i] | singleMasks[j]);
			}
		}

		int lim = (1 << n);
		int[] dp = new int[lim];

		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;

		int[] p = new int[lim];
		Arrays.fill(p, -1);

		for (int mask = 0; mask < lim; ++mask){
			if (dp[mask] == Integer.MAX_VALUE){
				continue;
			}

			int minBit = -1;

			for (int bit = 0; bit < n; ++bit){
				if (checkBit(mask, bit)) continue;

				if (minBit == -1 || (dist[minBit] > dist[bit])){
					minBit = bit;
				}
			}

			if (minBit == -1){
				continue;
			}

			for (int bit = 0; bit < n; ++bit){
				if (checkBit(mask, bit)) continue;

				int newMask = (mask | (1 << minBit) | (1 << bit));

				if (dp[newMask] > dp[mask] + d[minBit][bit]){
					dp[newMask] = dp[mask] + d[minBit][bit];
					p[newMask] = minBit * n + bit;
				}
			}
		}

		out.println(dp[lim-1]);

		int curMask = lim - 1;
		while (p[curMask] != -1){
			out.print("0 ");

			int first = p[curMask] / n;
			int second = p[curMask] % n;

			out.print((first + 1) + " ");
			curMask ^= (1 << first);

			if (first != second){
				out.print((second + 1) + " ");
				curMask ^= (1 << second);
			}
		}

		out.println("0");
	}

	private boolean checkBit(int mask, int bitNumber) {
		return (mask & (1 << bitNumber)) != 0;
	}

	boolean checkMask(int mask, int innerMask){
		return (mask & innerMask) == innerMask;
	}
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Task2 {

    public static void main(String[] args) throws IOException {

        new Task2().solve();

    }

    //ArrayList<Integer>[] g;

    int mod = 1000000007;

    PrintWriter out;

    int n;
    int m;
    //int[][] a = new int[1000][1000];

    //int cnt = 0;

    long base = (1L << 63);
    long P = 31;

    int[][] a;

    void solve() throws IOException {

        //Reader in = new Reader("in.txt");
        //out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        Reader in = new Reader();
        PrintWriter out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );

        //BufferedReader br = new BufferedReader( new FileReader("in.txt") );
        //BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );

        int sx = in.nextInt();
        int sy = in.nextInt();

        int n = in.nextInt();

        int[] x = new int[n];
        int[] y = new int[n];

        for (int i = 0; i < n; i++) {

            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }

        int[] dp = new int[1 << n];
        int[] p = new int[1 << n];

        int inf = 1000000000;

        Arrays.fill(dp, inf);
        dp[0] = 0;

        for (int mask = 0; mask < (1 << n) - 1; mask ++) {

            int k = -1;

            if (dp[mask] == inf)
                continue;

            for (int i = 0; i < n; i++) {

                if ((mask & (1 << i)) == 0) {

                    k = i;
                    break;
                }
            }

            for (int i = k; i < n; i++) {

                if ((mask & (1 << i)) == 0) {

                    int val = dp[mask] + dist(sx, sy, x[i], y[i]) + dist(sx, sy, x[k], y[k]) + dist(x[i], y[i], x[k], y[k]);

                    if (val < dp[mask | (1 << i) | (1 << k)]) {

                        dp[mask | (1 << i) | (1 << k)] = val;
                        p[mask | (1 << i) | (1 << k)] = mask;
                    }
                }
            }

        }

        out.println(dp[(1 << n) - 1]);

        int cur = (1 << n) - 1;

        out.print(0+" ");

        while (cur != 0) {

            int prev = p[cur];

            for (int i = 0; i < n; i++) {

                if (((cur & (1 << i)) ^ (prev & (1 << i))) != 0)
                    out.print(i+1+" ");
            }

            out.print(0+" ");

            cur = prev;
        }

        out.flush();
        out.close();
    }

    int dist(int x1, int y1, int x2, int y2) {

        return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
    }

    long gcd(long a, long b) {

        if (b == 0)
            return a;

        return gcd(b, a%b);

    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (b < p.b)
                return 1;

            if (b > p.b)
                return -1;

            return 0;
        }

        //		@Override
        //		public boolean equals(Object o) {
        //			Pair p = (Pair) o;
        //			return a == p.a && b == p.b;
        //		}
        //
        //		@Override
        //		public int hashCode() {
        //			return Integer.valueOf(a).hashCode() + Integer.valueOf(b).hashCode();
        //		}

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class LookingOrder {
    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] line=in.readLine().split("\\s+");
        int xs= Integer.parseInt(line[0]);
        int ys= Integer.parseInt(line[1]);
        int n=Integer.parseInt(in.readLine());
        int []x=new int[n];
        int []y=new int[n];
        for(int i=0;i<n;++i){
            line=in.readLine().split("\\s+");
            x[i]= Integer.parseInt(line[0]);
            y[i]= Integer.parseInt(line[1]);
        }
        int maxBitmap=1<<n;
        long[] dis=new long[maxBitmap];
        int[] last=new int[maxBitmap];
        dis[0]=0;
        int ci=0;
        int[][] dismap=new int[n][n];

        for(int i=0;i<n;++i){
            for(int j=0;j<=i;++j){
                int delx,dely;
                if(i==j){
                    delx=x[i]-xs;
                    dely=y[i]-ys;
                }else{
                    delx=x[i]-x[j];
                    dely=y[i]-y[j];
                }
                dismap[i][j]=delx*delx+dely*dely;
            }
        }

        for(int i=1;i<maxBitmap;++i){
            if((i&(1<<ci))==0)
                ++ci;
            int i2=i-(1<<ci);

            long min=dis[i2]+2*dismap[ci][ci];
            last[i]=ci;
            for(int j=0;j<ci;++j){
                if((i&(1<<j))!=0){
                    long m=dis[i2-(1<<j)]+dismap[ci][ci]+dismap[j][j]+dismap[ci][j];
                    if(m<min){
                        min=m;
                        last[i]=j;
                    }
                }
            }
            dis[i]=min;
        }

        out.write(""+dis[maxBitmap-1]);
        out.newLine();
        out.write("0");

        int bmap=maxBitmap-1;
        ci=n-1;
        while(bmap!=0){
            while((bmap&(1<<ci))==0&&ci>=0)--ci;
            int ci2=last[bmap];
            if(ci2!=ci){
                out.write(" "+(ci+1)+" "+(ci2+1)+ " 0");
                bmap-=(1<<ci)+(1<<ci2);
            }else{
                out.write(" "+(ci+1)+" 0");
                bmap-=1<<ci;
            }
        }
        out.close();
    }
}


import java.util.Scanner;

public class Round8_C {

	/**
	 * @param args
	 */

	int n ;
	int[] X, Y ;

	public Round8_C() {
		info_in() ;
		process() ;
	}

	void info_in()
	{
		Scanner input = new Scanner(System.in) ;
		int dx = input.nextInt() ;
		int dy = input.nextInt() ;

		n = input.nextInt() ;
		X = new int[n] ;
		Y = new int[n] ;

		for( int i=0;i<n;i++) {
			X[i] = input.nextInt() - dx ;
			Y[i] = input.nextInt() - dy ;
		}
	}

	int[] d  ;
	int[] trace ;

	public static int distance( int x1, int y1, int x2, int y2 )
	{
		return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ;
	}

	void process()
	{
		int gh = 1<<n ;
		d = new int[gh] ;
		trace = new int[gh] ;

		d[0] = 0 ;
		for( int i=1;i<gh;i++) {
			d[i] = Integer.MAX_VALUE ;
			for( int j=0;j<n;j++)
				if ( (i & (1<<j)) > 0 ) {
					int val = d[i^(1<<j)] + ( distance( X[j], Y[j], 0, 0 ) << 1 ) ;
					if ( val < d[i] ) {
						d[i] = val ;
						trace[i] = j+1 ;
					}

					int state = i ^ (1<<j) ;
					for( int p=j+1;p<n;p++)
						if ( (i & (1<<p)) > 0) {
							val = d[state^(1<<p)] + distance( X[j], Y[j], 0, 0 ) + distance( X[j], Y[j], X[p], Y[p] ) + distance( X[p], Y[p], 0, 0 ) ;
							if ( val < d[i] ) {
								d[i] = val ;
								trace[i] = (j+1) * 100 + (p+1) ;
							}
						}
					break ;
				}
		}

		System.out.println( d[gh-1] ) ;
		gh-- ;
		while ( gh > 0 ) {
			int v1 = trace[gh] / 100 - 1 ;
			int v2 = trace[gh] % 100 - 1 ;
			System.out.print(0 + " ") ;
			if ( v1 != -1 ) {
				System.out.print((v1+1) + " " ) ;
				gh -= 1 << v1 ;
			}
			System.out.print( (v2+1) + " " ) ;
			gh -= 1 << v2 ;
		}
		System.out.println(0) ;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Round8_C() ;
	}

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B {
    final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    final PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    StringTokenizer tokenizer;
    final int[][] d;
    final int n;
    final int[] time;
    final Action[] actions;

    private static final class Action {
        int a;
        int b;

        public Action(int a) {
            this.a = this.b = a;
        }

        public Action(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public String toString() {
            if (a == b)
                return " " + (a+1);
            return " " + (a+1) + " " + (b+1);
        }
    }

    private static final int dist(int x1, int y1, int x2, int y2) {
        return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    }

    private final boolean in(int x, int set) {
        return ((1 << x) & set) != 0;
    }

    private final int off(int x, int set) {
        return (set ^ (set & (1 << x)));
    }

    private final int solve(int set) {
        if (time[set] > 0)
            return time[set];
        int min = Integer.MAX_VALUE;
        if (set == 0)
            min = 0;
        else {
            int a;
            for (a = 0; a < n; a++)
                if (in(a, set))
                    break;
            int subset = off(a, set);
            int aux = 2 * d[a][a] + solve(subset);
            if (aux < min) {
                min = aux;
                actions[set] = new Action(a);
            }
            for (int b = a + 1; b < n; b++)
                if (in(b, subset)) {
                    aux = d[a][a] + d[b][b] + d[a][b] + solve(off(b, subset));
                    if (aux < min) {
                        min = aux;
                        actions[set] = new Action(a, b);
                    }
                }
        }
        time[set] = min;
        return min;
    }

    private B() throws IOException {
        int bx = nextInt();
        int by = nextInt();
        n = nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = nextInt();
            y[i] = nextInt();
        }
        reader.close();

        d = new int[n][n];
        for (int i = 0; i < n; i++) {
            d[i][i] = dist(bx, by, x[i], y[i]);// |A|
            for (int j = i + 1; j < n; j++)
                d[i][j] = dist(x[i], y[i], x[j], y[j]);// |AB|
        }
        int set = 1 << n;
        time = new int[set];
        actions = new Action[set];
        set--;
        printer.println(solve(set));
        printer.print("0");
        while (set != 0) {
            solve(set);
            Action action = actions[set];
            printer.print(action);
            printer.print(" 0");
            set = off(action.a, set);
            set = off(action.b, set);
        }

        printer.println();
        printer.close();
    }

    private final int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private final String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public static void main(String[] args) throws IOException {
        new B();
    }

}


import java.util.*;
public class c8 {
    static int n;
    static int[] ds;
    static int[][] g;
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int x = input.nextInt(), y = input.nextInt();
    int n = input.nextInt();
    int[] xs = new int[n], ys = new int[n];
    for(int i = 0; i<n; i++)
    {
        xs[i] = input.nextInt();
        ys[i] = input.nextInt();
    }
    ds = new int[n];
    g = new int[n][n];
    for(int i = 0; i<n; i++)
    {
        ds[i] = (x - xs[i])  *  (x - xs[i]) + (y - ys[i]) * (y - ys[i]);
        for(int j = 0; j<n; j++)
        {
            g[i][j] = (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
        }
    }
    int[] dp = new int[1<<n];
    Arrays.fill(dp, 987654321);
    dp[0] = 0;
    for(int i = 0; i<(1<<n); i++)
    {
        if(dp[i] == 987654321) continue;
        for(int a = 0; a<n; a++)
        {
            if((i & (1<<a)) > 0) continue;
            dp[i | (1<<a)] = Math.min(dp[i | (1<<a)], dp[i] + 2*ds[a]);
            for(int b = a+1; b<n; b++)
            {
                if((i & (1<<b)) > 0) continue;
                dp[i | (1<<a) | (1<<b)] = Math.min(dp[i | (1<<a) | (1<<b)], dp[i] + ds[a] + ds[b] + g[a][b]);
            }
            break;
        }
    }
    Stack<Integer> stk = new Stack<Integer>();
    stk.add(0);
    int i = (1<<n) - 1;
    //System.out.println(Arrays.toString(dp));

    trace:
    while(i > 0)
    {
        //System.out.println(i);
        for(int a = 0; a<n; a++)
        {
            if((i & (1<<a)) == 0) continue;
            if( dp[i] == dp[i - (1<<a)] + 2*ds[a])
            {
                stk.add(a+1);
                stk.add(0);
                i -= (1<<a);
                continue trace;
            }
            for(int b = a+1; b<n; b++)
            {
                if((i & (1<<b)) == 0) continue;
                if(dp[i] == dp[i - (1<<a) - (1<<b)] + ds[a] + ds[b] + g[a][b])
                {
                    stk.add(a+1);
                    stk.add(b+1);
                    stk.add(0);
                    i -= (1<<a) + (1<<b);
                    continue trace;
                }
            }
            //break;
        }
    }
    System.out.println(dp[(1<<n) - 1]);
    while(!stk.isEmpty()) System.out.print(stk.pop()+" ");
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class LookingForOrder {
static int n;
static int []x,y,memo;
static StringBuilder sb;
static int distance(int i,int j)
{
	int dx=x[i]-x[j];
	int dy=y[i]-y[j];
	return dx*dx+dy*dy;
}
public static int dp(int msk)
{
	if(msk==(1<<(n+1))-2)
		return 0;
	if(memo[msk]!=-1)
		return memo[msk];
	int ans=10000000;
	boolean found=false;
	for(int i=1;i<=n && !found;i++)

		for(int j=i;j<=n && (msk&1<<i)==0;j++)
			if((msk&1<<j)==0)
			{

				found=true;
				int newM=msk|1<<i;
				newM|=1<<j;
				ans=Math.min(ans, dp(newM)+Math.min(distance(0,i)+distance(i,j)+distance(j,0), distance(0,j)+distance(j,i)+distance(i,0)));
			}
	return memo[msk]=ans;

}
public static void print(int msk)
{
	if(msk==(1<<(n+1))-2)
		return ;

	for(int i=1;i<=n;i++)

		for(int j=i;j<=n && (msk&1<<i)==0;j++)
			if((msk&1<<j)==0)
			{

				int newM=msk|1<<i;
				newM|=1<<j;
				int d1=distance(0,i)+distance(i,j)+distance(j,0);
				int d2=distance(0,j)+distance(j,i)+distance(i,0);
				if(dp(msk)== dp(newM)+Math.min(d1,d2))
				{

					if(i==j)

						sb.append("0 "+i+" ");

					else if(d1<d2)
						sb.append("0 "+i+" "+j+" ");
					else
						sb.append("0 "+j+" "+i+" ");

					print(newM);
					return ;
				}
			}

}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int xS=sc.nextInt(),yS=sc.nextInt();
		n=sc.nextInt();
		x=new int [n+1];
		y=new int [n+1];
		x[0]=xS;y[0]=yS;
		for(int i=1;i<=n;i++)
		{
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();

		}
		memo=new int [1<<(n+1)];
		Arrays.fill(memo,-1);
		sb=new StringBuilder();

		sb.append(dp(0)+"\n");
		print(0);
		sb.append("0");
		System.out.println(sb);
	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());

		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Bag implements Runnable {
    private void solve() throws IOException {
        int xs = nextInt();
        int ys = nextInt();
        int n = nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; ++i) {
            x[i] = nextInt();
            y[i] = nextInt();
        }
        final int[][] pair = new int[n][n];
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j)
                pair[i][j] = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys) + (x[j] - xs) * (x[j] - xs) + (y[j] - ys) * (y[j] - ys) + (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
        final int[] single = new int[n];
        for (int i = 0; i < n; ++i) {
            single[i] = 2 * ((x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys));
        }
        final int[] best = new int[1 << n];
        final int[] prev = new int[1 << n];
        for (int set = 1; set < (1 << n); ++set) {
            int i;
            for (i = 0; i < n; ++i)
                if ((set & (1 << i)) != 0)
                    break;
            best[set] = best[set ^ (1 << i)] + single[i];
            prev[set] = 1 << i;
            int nextSet = set ^ (1 << i);
            int unoI = 1 << i;
            for (int j = i + 1, unoJ = 1 << (i + 1); j < n; ++j, unoJ <<= 1)
                if ((set & unoJ) != 0) {
                    int cur = best[nextSet ^ unoJ] + pair[i][j];
                    if (cur < best[set]) {
                        best[set] = cur;
                        prev[set] = unoI | unoJ;
                    }
                }
        }
        writer.println(best[(1 << n) - 1]);
        int now = (1 << n) - 1;
        writer.print("0");
        while (now > 0) {
        	int differents = prev[now];
        	for(int i = 0; i < n; i++)
				if((differents & (1 << i)) != 0)
				{
					 writer.print(" ");
		             writer.print(i + 1);
		             now ^= 1 << i;
				}
            writer.print(" ");
            writer.print("0");
        }
        writer.println();
    }

    public static void main(String[] args) {
        new Bag().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class B {
    static int[][] dist;
    static int[] dist1;
    static int [] dp;
    static int [] path;
    static int end,x,y;
    static Point[] a;
    public static int doit(int mask) {
        if(mask==end) return 0;
        if(dp[mask]!=-1) return dp[mask];
        int min=Integer.MAX_VALUE;
        int t;
        int i;
        for(i=0;i<dist.length;i++)
            if(((1<<i)|mask)!=mask) break;
            t=2*dist1[i]+doit(mask|(1<<i));
            if(t<min) {
                min=t;
                path[mask]=(1<<i);
            }

            for(int j=i+1;j<dist.length;j++) {
                if(((1<<j)|mask)==mask) continue;
                t=dist[i][j]+doit(mask|(1<<i)|(1<<j));
                if(t<min) {
                    min=t;
                    path[mask]=(1<<i)|(1<<j);
                }
            }

        return dp[mask]=min;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
         x=sc.nextInt();y=sc.nextInt();
         a=new Point[sc.nextInt()];
        for(int i=0;i<a.length;i++) {
            a[i]=new Point(sc.nextInt(), sc.nextInt());
        }
        end=(1<<a.length)-1;
        dp=new int[1<<a.length];
        Arrays.fill(dp, -1);
        dist=new int[a.length][a.length];
        dist1=new int[a.length];
        for(int i=0;i<a.length;i++) {
            dist1[i]=(a[i].x-x)*(a[i].x-x)+(a[i].y-y)*(a[i].y-y);
            for(int j=i+1;j<a.length;j++) {

                dist[i][j]=dist1[i]+
                (a[j].x-a[i].x)*(a[j].x-a[i].x)+(a[j].y-a[i].y)*(a[j].y-a[i].y)+
                (a[j].x-x)*(a[j].x-x)+(a[j].y-y)*(a[j].y-y);
                //System.out.println(dist[i][j]);
            }
        }
        path=new int[dp.length];
        System.out.println(doit(0));
        int e=0;
        int cur=path[e];
        StringBuffer bf=new StringBuffer();
        bf.append(0+" ");
        int count=0;
        for(int i=0;count<a.length;i++) {
            //System.out.println(Integer.toBinaryString(cur)+" "+cur);
            for(int j=0;j<a.length;j++) {
                if(((1<<j)|cur)==cur) {
                    bf.append((j+1)+" "); count++;
                }
            }
            e|=cur;
            cur=path[e];
            bf.append(0+" ");
        }
        System.out.println(bf);
    }
}


import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));
		//Scanner skek = new Scanner(System.in);
		PrintWriter outkek = new PrintWriter(System.out);

		String[] input = kek.readLine().split(" ");
		int X0 = Integer.parseInt(input[0]), Y0 = Integer.parseInt(input[1]), N = Integer.parseInt(kek.readLine());

		int[] xCoords = new int[N + 1];
		int[] yCoords = new int[N + 1];
		int[][] distances = new int[N + 1][N + 1];
		xCoords[N] = X0;
		yCoords[N] = Y0;

		for(int i = 0; i < N; i++){
			input = kek.readLine().split(" ");
			xCoords[i] = Integer.parseInt(input[0]);
			yCoords[i] = Integer.parseInt(input[1]);
		}

		for(int i = 0; i <= N; i++){
			for(int j = i + 1; j <= N; j++){
				int temp = xCoords[i] - xCoords[j];
				int temp2 = yCoords[i] - yCoords[j];
				distances[i][j] = (temp * temp) + (temp2 * temp2);
			}
		}

		int[] aa = new int[1 << N];
		int[] bb = new int[1 << N];

		for(int i = 1; i < 1 << N; i++){
			int a = -1;
			for(int j = 0; j < N; j++){
				if((i & 1 << j) > 0){
					a = j;
					break;
				}
			}

			int l = i ^ 1 << a;
			int dist = distances[a][N] + distances[a][N];
			aa[i] = aa[l] + dist;
			bb[i] = l;

			for(int k = a + 1; k < N; k++){
				if((i & 1 << k) > 0) {
					l = i ^ 1 << a ^ 1 << k;
					dist = distances[a][N] + distances[k][N] + distances[a][k];
					if(aa[l] + dist < aa[i]){
						aa[i] = aa[l] + dist;
						bb[i] = l;
					}
				}
			}
		}

		int fin = (1 << N) - 1;
		outkek.println(aa[fin]);
		outkek.print('0');
		while (fin != 0){
			int temp1 = bb[fin];
			int temp2 = fin ^ temp1;
			for(int i = 0; i < N; i++){
				if((temp2 & 1 << i) > 0){
					outkek.print(" " + (i + 1));
				}
			}
			outkek.print(" 0");
			fin = temp1;
		}
		kek.close();
		outkek.close();
	}

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class CF008C {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int y = s.nextInt();
        int n = s.nextInt();
        int[] xx = new int[n+1];
        int[] yy = new int[n+1];
        for(int i = 0;i<n;i++){
            xx[i] = s.nextInt();
            yy[i] = s.nextInt();
        }
//        int[][] dp = new int[n][n];
//        for(int i = 0;i<n;i++){
//            Arrays.fill(dp[i],-1);
//        }
        xx[n] = x;
        yy[n] = y;
        int[][] dp = new int[n + 1][n + 1];
        for (int i = 0; i <= n; i++)
            for (int j = i + 1; j <= n; j++) {
                int dx = xx[i] - xx[j];
                int dy = yy[i] - yy[j];
                dp[i][j] = dx * dx + dy * dy;
            }
            int[] aa = new int[1 << n];
            int[] bb = new int[1 << n];
            for (int k = 1; k < 1 << n; k++) {
                int a = -1;
                for (int b = 0; b < n; b++)
                    if ((k & 1 << b) > 0) {
                        a = b;
                        break;
                    }
                int l = k ^ 1 << a;
                int d = dp[a][n] + dp[a][n];
                aa[k] = aa[l] + d;
                bb[k] = l;
                for (int b = a + 1; b < n; b++)
                    if ((k & 1 << b) > 0) {
                        l = k ^ 1 << a ^ 1 << b;
                        d = dp[a][n] + dp[b][n] + dp[a][b];
                        if (aa[l] + d < aa[k]) {
                            aa[k] = aa[l] + d;
                            bb[k] = l;
                        }
                    }
            }
            int k = (1 << n) - 1;
            System.out.println(aa[k]);
            StringBuilder sb = new StringBuilder();
            sb.append(0);
            while (k != 0) {
                int l = bb[k];
                int m = k ^ l;
                for (int b = 0; b < n; b++)
                    if ((m & 1 << b) > 0)
                        sb.append(' ').append(b + 1);
                sb.append(' ').append(0);
                k = l;
            }
            System.out.println(sb);
        }
//        int[] distFromOrigin = new int[n];
////        HashMap<Integer,Boolean> map = new HashMap<>();
//        for(int i=0;i<n;i++){
//            distFromOrigin[i] = (int) (Math.pow((xCoord[i] - x),2) + Math.pow(yCoord[i] - y,2));
////            map.put(i,true);
//        }
//        System.out.println(0);
//        long sum = 0;
//        String str = "0 ";
//
//        while(!map.isEmpty()){
//            int first = 0;
//            int second = Integer.MIN_VALUE;
//            if(map.size() == 1){
//                first = new ArrayList<Integer>(map.keySet()).get(0) + 1;
//                int min = distFromOrigin[first - 1] + distFromOrigin[first - 1];
//                sum += min;
//                map.remove(first - 1);
//            }else {
//                int min = Integer.MAX_VALUE;
//
//                for (int i = 0; i < n; i++) {
//                    for (int j = 0; j <= i; j++) {
//                        if (map.containsKey(i) && map.containsKey(j) && distFromOrigin[i] + distFromOrigin[j] + dp[i][j] < min) {
//                            min = distFromOrigin[i] + distFromOrigin[j] + dp[i][j];
//                            first = i + 1;
//                            if(i == j){
//                                second = Integer.MIN_VALUE;
//                            }else {
//                                second = j + 1;
//                            }
//                        }
//                    }
//                }
//                sum += min;
//                map.remove(first - 1);
//                if(second != Integer.MIN_VALUE){
//                    map.remove(second - 1);
//                }
//            }
//            if(second == Integer.MIN_VALUE){
//                str = str + first + " ";
//            }else{
//                if(map.size() == 0) {
//                    str = str + first + " " + second + " ";
//                }else{
//                    str = str + first + " " + second + " 0 ";
//                }
//            }
////            System.out.print(first + " " + second + " ");
//        }
//        System.out.println(sum);
//        System.out.println(str + "0");
//        int[] ans = new int[(int)Math.pow(2,n)];
//        Arrays.fill(ans,Integer.MAX_VALUE);
//        for(int i = 0;i<Math.pow(2,n);i++){
//            for(int j = 0;j<n;j++){
//                //I can't figure out how to do that.
//            }
//        }
//        System.out.print(sum);
//        System.out.print(0);

    private static int calculateDistanceBetweenIandJ(int[] xCoord, int[] yCoord, int i, int j) {
        int length = (int) (Math.pow((xCoord[i] - xCoord[j]),2) + Math.pow(yCoord[i] - yCoord[j], 2));
        return length;
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int INF = 1000 * 1000 * 1000;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x0 = in.readInt();
            int y0 = in.readInt();
            int n = in.readInt();
            int[] xs = new int[n + 1], ys = new int[n + 1];
            xs[0] = x0;
            ys[0] = y0;
            for (int i = 1; i <= n; i++) {
                xs[i] = in.readInt();
                ys[i] = in.readInt();
            }
            int[] one = new int[n];
            for (int i = 0; i < n; i++) one[i] = dist(0, i + 1, xs, ys) * 2;
            int[][] two = new int[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    two[i][j] = dist(0, i + 1, xs, ys) + dist(0, j + 1, xs, ys) + dist(i + 1, j + 1, xs, ys);
                }
            }
            int[] dp = new int[(1 << n)];
            Arrays.fill(dp, INF);
            dp[0] = 0;
            int[] prev = new int[(1 << n)];
            for (int mask = 0; mask < (1 << n); mask++) {
                for (int i = 0; i < n; i++) {
                    if (((mask >> i) & 1) != 0) continue;
                    ;
                    int nmask = mask | (1 << i);
                    int cost = one[i] + dp[mask];
                    if (cost < dp[nmask]) {
                        dp[nmask] = cost;
                        prev[nmask] = i;
                    }
                    for (int j = i + 1; j < n; j++) {
                        if (((mask >> j) & 1) != 0) continue;
                        int nnmask = nmask | (1 << j);
                        cost = two[i][j] + dp[mask];
                        if (cost < dp[nnmask]) {
                            dp[nnmask] = cost;
                            prev[nnmask] = n + i * n + j;
                        }
                    }
                    break;
                }
            }
            int mask = (1 << n) - 1;
            out.printLine(dp[mask]);
            ArrayList<Integer> res = new ArrayList<>();
            res.add(0);
            while (mask > 0) {
                if (prev[mask] < n) {
                    res.add(prev[mask] + 1);
                    mask &= ~(1 << prev[mask]);
                } else {
                    int ii = (prev[mask] - n) / n;
                    int jj = (prev[mask] - n) % n;
                    int i = Math.max(ii, jj);
                    int j = Math.min(ii, jj);
                    res.add(i + 1);
                    res.add(j + 1);
                    mask &= ~(1 << i);
                    mask &= ~(1 << j);
                }
                res.add(0);
            }
            Collections.reverse(res);
            for (int val : res) out.print(val + " ");
            out.printLine();
        }

        int dist(int i, int j, int[] xs, int[] ys) {
            return (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }
    }
}


import java.io.*;
import java.util.*;

import com.sun.swing.internal.plaf.basic.resources.basic;

public class Main {

	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

	private void solution() throws IOException {
		int sx = in.nextInt();
		int sy = in.nextInt();
		int n = in.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; ++i) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}
		int[] dp = new int[1 << n];
		int[] prev = new int[1 << n];
		Arrays.fill(dp, Integer.MAX_VALUE / 2);
		dp[0] = 0;
		prev[0] = -1;
		for (int mask = 0; mask < (1 << n); ++mask) {
			if (dp[mask] != Integer.MAX_VALUE / 2) {
				for (int next = 0; next < n; ++next) {
					if (((mask >> next) & 1) == 0) {
						int nmask = mask | (1 << next);
						int val = dp[mask] + 2 * getDist(sx, sy, x[next], y[next]);
						if (dp[nmask] > val) {
							dp[nmask] = val;
							prev[nmask] = mask;
						}
						for (int next2 = next + 1; next2 < n; ++next2) {
							if (((nmask >> next2) & 1) == 0) {
								int nnmask = nmask | (1 << next2);
								int nval = dp[mask] + getDist(sx, sy, x[next], y[next])
													+ getDist(x[next], y[next], x[next2], y[next2])
													+ getDist(x[next2], y[next2], sx, sy);
								if (dp[nnmask] > nval) {
									dp[nnmask] = nval;
									prev[nnmask] = mask;
								}
							}
						}
						break;
					}
				}
			}
		}
		List<Integer> res = new ArrayList<Integer>();
		res.add(0);
		int mask = (1 << n) - 1;
		while (mask > 0) {
			for (int i = 0; i < n; ++i) {
				if (((prev[mask] >> i) & 1) == 0 && ((mask >> i) & 1) == 1) {
					res.add(i + 1);
				}
			}
			res.add(0);
			mask = prev[mask];
		}
		Collections.reverse(res);
		out.println(dp[(1 << n) - 1]);
		for (int i = 0; i < res.size(); ++i) {
			if (i != 0) {
				out.print(" ");
			}
			out.print(res.get(i));
		}
		out.println();
		out.flush();
	}

	private int getDist(int x1, int y1, int x2, int y2) {
		return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	}

	private class Scanner {

		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public Scanner(Reader in) {
			reader = new BufferedReader(in);
			tokenizer = new StringTokenizer("");
		}

		public boolean hasNext() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String tmp = reader.readLine();
				if (tmp == null)
					return false;
				tokenizer = new StringTokenizer(tmp);
			}
			return true;
		}

		public String next() throws IOException {
			hasNext();
			return tokenizer.nextToken();
		}

		public String nextLine() throws IOException {
			tokenizer = new StringTokenizer("");
			return reader.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] args) throws IOException {
		new Main().solution();
	}
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class BetaRound8_C implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;

    @Override
    public void run() {
        try {
            long startTime = System.currentTimeMillis();
            if (System.getProperty("ONLINE_JUDGE") != null) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            tok = new StringTokenizer("");
            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long endTime = System.currentTimeMillis();
            long totalMemory = Runtime.getRuntime().totalMemory();
            long freeMemory = Runtime.getRuntime().freeMemory();
            System.err.println("Time = " + (endTime - startTime) + " ms");
            System.err.println("Memory = " + ((totalMemory - freeMemory) / 1024) + " KB");
        } catch (Throwable e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static void main(String[] args) {
        new Thread(null, new BetaRound8_C(), "", 256 * 1024 * 1024).start();
    }

    // ------------------------------------------------------------------------------

    final int INF = 1000 * 1000 * 1000;

    int x0, y0;
    int n;
    int[] x, y;

    int t(int i, int j) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        return dx * dx + dy * dy;
    }

    int t0(int i) {
        int dx = x[i] - x0;
        int dy = y[i] - y0;
        return dx * dx + dy * dy;
    }

    int[] dp;
    int[] p;

    void solve() throws IOException {
        x0 = readInt();
        y0 = readInt();
        n = readInt();
        x = new int[n];
        y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = readInt();
            y[i] = readInt();
        }
        dp = new int[1 << n];
        p = new int[1 << n];
        Arrays.fill(dp, INF);
        dp[(1 << n) - 1] = 0;
        get(0);
        out.println(dp[0]);
        printPath();
    }

    int get(int mask) {
        if (dp[mask] != INF) {
            return dp[mask];
        }
        int res = INF;
        for (int i = 0; i < n; i++) {
            if (((1 << i) & mask) == 0) { // порядок неважен, т.к. в i все равно идти, пойдем туда сразу
                int test = get(mask ^ (1 << i)) + 2 * t0(i);
                if (res > test) {
                    res = test;
                    p[mask] = mask ^ (1 << i);
                }
                for (int j = i + 1; j < n; j++) {
                    if (((1 << j) & mask) == 0) {
                        test = get(mask ^ (1 << i) ^ (1 << j)) + t0(i)
                                + t(i, j) + t0(j);
                        if (res > test) {
                            res = test;
                            p[mask] = mask ^ (1 << i) ^ (1 << j);
                        }
                    }
                }
                break;
            }
        }
        return dp[mask] = res;
    }

    void printPath() {
        ArrayList<Integer> ans = new ArrayList<Integer>();
        ans.add(0);
        int mask = 0;
        while (mask != (1 << n) - 1) {
            for (int i = 0; i < n; i++) {
                if (((mask ^ p[mask]) & (1 << i)) != 0) {
                    ans.add(i + 1);
                }
            }
            mask = p[mask];
            ans.add(0);
        }
        for (int x : ans) {
            out.print(x + " ");
        }
    }

}


import java.io.*;
import java.util.*;

public class Main {
	private void run() throws IOException {
		int cx = in.nextInt();
		int cy = in.nextInt();
		int n = in.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; ++i) {
			x[i] = in.nextInt() - cx;
			y[i] = in.nextInt() - cy;
		}
		int[] dp = new int[1 << n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		int[] prev = new int[1 << n];
		for (int mask = 0; mask < (1 << n); ++mask) {
			if (dp[mask] == Integer.MAX_VALUE) {
				continue;
			}
			for (int i = 0; i < n; ++i) {
				if (((mask >> i) & 1) == 0) {
					if (dp[mask | (1 << i)] > dp[mask] + dist(x[i], y[i])) {
						dp[mask | (1 << i)] = dp[mask] + dist(x[i], y[i]);
						prev[mask | (1 << i)] = mask;
					}
					for (int j = i + 1; j < n; ++j) {
						if (((mask >> j) & 1) == 0) {
							if (dp[mask | (1 << i) | (1 << j)] > dp[mask] + dist(x[i], y[i], x[j], y[j])) {
								dp[mask | (1 << i) | (1 << j)] = dp[mask] + dist(x[i], y[i], x[j], y[j]);
								prev[mask | (1 << i) | (1 << j)] = mask;
							}
						}
					}
					break;
				}
			}
		}
		out.println(dp[(1 << n) - 1]);
		int mask = (1 << n) - 1;
		out.print(0);
		while (mask != 0) {
			int p = prev[mask];
			int cur = p ^ mask;
			List<Integer> who = new ArrayList<Integer>();
			for (int i = 0; i < n; ++i) {
				if (((cur >> i) & 1) != 0) {
					who.add(i + 1);
				}
			}
			for (int t : who) {
				out.print(" " + t);
			}
			out.print(" " + 0);
			mask = p;
		}
		out.flush();
	}

	private int dist(int x, int y, int x2, int y2) {
		return x * x + y * y + x2 * x2 + y2 * y2 + (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);
	}

	private int dist(int x, int y) {
		return 2 * (x * x + y * y);
	}

	private class Scanner {
		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public Scanner(Reader in) {
			reader = new BufferedReader(in);
			tokenizer = new StringTokenizer("");
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean hasNext() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String next = reader.readLine();
				if (next == null)
					return false;
				tokenizer = new StringTokenizer(next);
			}
			return true;
		}

		public String next() throws IOException {
			hasNext();
			return tokenizer.nextToken();
		}

		public String nextLine() throws IOException {
			tokenizer = new StringTokenizer("");
			return reader.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	Scanner in = new Scanner(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class MainC {

    private FastScanner in;
    private PrintWriter out;

    private int N;
    private Dist[] dists;
    private int countDists;
    private int[][] minLeft;// startsFrom, count

    private int[] minOrder;
    private int minOrderCount = 10000000;

    public void solve() throws IOException {
        int xb = in.nextInt();
        int yb = in.nextInt();
        N = in.nextInt();
        int[] x, y;
        boolean isOdd;
        if (N % 2 == 0) {
            x = new int[N];
            y = new int[N];
            isOdd = false;
        }
        else {
            x = new int[N + 1];
            y = new int[N + 1];
            isOdd = true;
        }
        for (int i = 0; i < N; i++) {
            x[i] = in.nextInt() - xb;
            y[i] = in.nextInt() - yb;
        }
        if (N % 2 == 1) {
            N++;
            x[N - 1] = 0;
            y[N - 1] = 0;
        }

        countDists = N * (N - 1) / 2;
        dists = new Dist[countDists];
        int c = 0;
        int commonSum = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                dists[c] = new Dist();
                dists[c].from = i;
                dists[c].to = j;
                dists[c].dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j])
                                * (y[i] - y[j]);
                dists[c].dist = Math.min(dists[c].dist, x[i] * x[i] + y[i]
                                * y[i] + x[j] * x[j] + y[j] * y[j]);
                c++;
            }
            commonSum += x[i] * x[i] + y[i] * y[i];
        }

        Arrays.sort(dists);

        minLeft = new int[countDists][N + 1];
        for (int i = 0; i < countDists; i++) {
            int sum = 0;
            for (int j = 1; j <= N; j++) {
                if (i + j - 1 < countDists) {
                    sum = sum + dists[i + j - 1].dist;
                    minLeft[i][j] = sum;
                }
                else {
                    minLeft[i][j] = 100000000;
                }
            }
        }

        order(0, new int[N], 0, 0);

        out.println(minOrderCount + commonSum);
        for (int i = 1; i <= N / 2; i++) {
            int first = -1;
            int second = -1;
            for (int j = 0; j < N; j++) {
                if (minOrder[j] == i) {
                    if (first == -1) {
                        first = j;
                    }
                    else {
                        second = j;
                    }
                }
            }

            if (isOdd && (first == N - 1 || second == N - 1)) {
                first++;
                second++;
                out.print("0 " + (first + second - N) + " ");
            }
            else if (x[first] * x[first] + y[first] * y[first] + x[second]
                            * x[second] + y[second] * y[second] < (x[first] - x[second])
                            * (x[first] - x[second])
                            + (y[first] - y[second])
                            * (y[first] - y[second])) {
                first++;
                second++;
                out.print("0 " + first + " 0 " + second + " ");
            }
            else {
                first++;
                second++;
                out.print("0 " + first + " " + second + " ");
            }
        }

        out.println("0");
    }

    private void order(int countOrdered, int[] order, int startsFrom, int sum) {
        if (countOrdered == N) {
            if (sum < minOrderCount) {
                minOrder = Arrays.copyOf(order, N);
                minOrderCount = sum;
            }
            return;
        }

        while (startsFrom < countDists) {
            if (order[dists[startsFrom].from] == 0
                            && order[dists[startsFrom].to] == 0) {
                if (minLeft[startsFrom][(N - countOrdered) / 2] + sum >= minOrderCount) {
                    break;
                }
                order[dists[startsFrom].from] = countOrdered / 2 + 1;
                order[dists[startsFrom].to] = countOrdered / 2 + 1;
                order(countOrdered + 2, order, startsFrom + 1, sum
                                + dists[startsFrom].dist);
                order[dists[startsFrom].from] = 0;
                order[dists[startsFrom].to] = 0;
            }
            startsFrom++;
        }
    }

    private class Dist implements Comparable<Dist> {

        int from;
        int to;
        int dist;

        @Override
        public int compareTo(Dist o) {
            if (dist < o.dist) {
                return -1;
            }
            if (dist == o.dist) {
                return 0;
            }
            return 1;
        }
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] arg) {
        new MainC().run();
    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {
		//long t = System.currentTimeMillis();
		new C().run();
		//System.out.println(System.currentTimeMillis() - t);
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();
		int[] w = new int[n * n];
		int[] pMask = new int[n * n];
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				int ind = i * n + j;
				if (i == j) {
					w[ind] = 2 * dist(sx, sy, x[i], y[i]);
					pMask[ind] = 1 << i;
				} else {
					w[ind] = dist(sx, sy, x[i], y[i]) + dist(x[i], y[i], x[j], y[j]) + dist(x[j], y[j], sx, sy);
					pMask[ind] = 1 << i | 1 << j;
				}
			}
		}
		int max = 1 << n;
		int[] p = new int[max];
		int[] dist = new int[max];
		Arrays.fill(dist, Integer.MAX_VALUE / 2);
		dist[0] = 0;
		int[] available = new int[n * n];
		for (int mask = 0; mask < max; mask++) {
			int ac = 0;
			for (int i = 0; i < n; i++) {
				if (((mask >> i) & 1) == 0) {
					available[ac++] = i;
				}
			}
			int s = 0;
			//for (int i = 0; i < ac; i++) {
				for (int j = s; j < ac; j++) {
					int a = available[s];
					int b = available[j];
					int ind = a * n + b;
					int nextMask = mask | pMask[ind];
					int newD = dist[mask] + w[ind];
					if (newD < dist[nextMask]) {
						dist[nextMask] = newD;
						//p[nextMask] = a * n + b;
						p[nextMask] = ind;
					}
				}
			//}
		}
		System.out.println(dist[max - 1]);
		ArrayList<Integer> steps = new ArrayList<Integer>();
		int mask = max - 1;
		while (mask > 0) {
			int msk = p[mask];
			steps.add(msk);
			int a = msk / n;
			int b = msk % n;
			if (a == b) {
				mask ^= 1 << a;
			} else {
				mask ^= 1 << a;
				mask ^= 1 << b;
			}
		}
		System.out.print(0);
		for (int i = steps.size() - 1; i >= 0; i--) {
			int msk = steps.get(i);
			int a = msk / n;
			int b = msk % n;
			if (a == b) {
				System.out.printf(" %d 0", a + 1);
			} else {
				System.out.printf(" %d %d 0", a + 1, b + 1);
			}
		}
		System.out.println();
	}

	private int dist(int x1, int y1, int x2, int y2) {
		return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	}

}


import java.util.*;
public class c8 {
    static int n;
    static int[] ds;
    static int[][] g;
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int x = input.nextInt(), y = input.nextInt();
    n = input.nextInt();
    int[] xs = new int[n], ys = new int[n];
    for(int i = 0; i<n; i++)
    {
        xs[i] = input.nextInt();
        ys[i] = input.nextInt();
    }
    ds = new int[n];
    g = new int[n][n];
    for(int i = 0; i<n; i++)
    {
        ds[i] = (x - xs[i])  *  (x - xs[i]) + (y - ys[i]) * (y - ys[i]);
        for(int j = 0; j<n; j++)
        {
            g[i][j] = (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
        }
    }
    int[] dp = new int[1<<n];
    Arrays.fill(dp, 987654321);
    dp[0] = 0;
    for(int i = 0; i<(1<<n); i++)
    {
        if(dp[i] == 987654321) continue;
        for(int a = 0; a<n; a++)
        {
            if((i & (1<<a)) > 0) continue;
            dp[i | (1<<a)] = Math.min(dp[i | (1<<a)], dp[i] + 2*ds[a]);
            for(int b = a+1; b<n; b++)
            {
                if((i & (1<<b)) > 0) continue;
                dp[i | (1<<a) | (1<<b)] = Math.min(dp[i | (1<<a) | (1<<b)], dp[i] + ds[a] + ds[b] + g[a][b]);
            }
            break;
        }
    }
    Stack<Integer> stk = new Stack<Integer>();
    stk.add(0);
    int i = (1<<n) - 1;
    //System.out.println(Arrays.toString(dp));

    trace:
    while(i > 0)
    {
        //System.out.println(i);
        for(int a = 0; a<n; a++)
        {
            if((i & (1<<a)) == 0) continue;
            if( dp[i] == dp[i - (1<<a)] + 2*ds[a])
            {
                stk.add(a+1);
                stk.add(0);
                i -= (1<<a);
                continue trace;
            }
            for(int b = a+1; b<n; b++)
            {
                if((i & (1<<b)) == 0) continue;
                if(dp[i] == dp[i - (1<<a) - (1<<b)] + ds[a] + ds[b] + g[a][b])
                {
                    stk.add(a+1);
                    stk.add(b+1);
                    stk.add(0);
                    i -= (1<<a) + (1<<b);
                    continue trace;
                }
            }
            //break;
        }
    }
    System.out.println(dp[(1<<n) - 1]);
    while(!stk.isEmpty()) System.out.print(stk.pop()+" ");
}
}


import java.util.*;
import java.io.*;

public class C0008 {

    public static void main(String args[]) throws Exception {
        new C0008();
    }

    int n;
    int target;
    int pow[];
    int dp[];
    int next[];
    int dist[][];

    C0008() throws Exception {
        PandaScanner sc = null;
        PrintWriter out = null;
        try {
            sc = new PandaScanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception ignored) {
        }

        pow = new int[26];
        for (int i = 0; i < 26; i++) {
            pow[i] = 1 << i;
        }

        dist = new int[26][26];
        int[][] p = new int[26][];
        p[25] = new int[] {sc.nextInt(), sc.nextInt()};
        n = sc.nextInt();
        target = (1 << n) - 1;

        for (int i = 0; i < n; i++) {
            p[i] = new int[] {sc.nextInt(), sc.nextInt()};
            dist[i][25] = getDist(p[i], p[25]);
            for (int j = 0; j < i; j++) {
                dist[j][i] = getDist(p[j], p[i]);
            }
        }

        next = new int[1 << n];

        dp = new int[1 << n];
        Arrays.fill(dp, -1);

        out.println(go(0));

        ArrayList<Integer> paths = new ArrayList<Integer>();
        paths.add(0);
        int curr = 0;
        while (curr != target) {
            for (Integer i: getBits(next[curr], true)) {
                paths.add(i + 1);
            }
            paths.add(0);
            curr |= next[curr];
        }
        out.println(paths.toString().replaceAll("[^ 0-9]", ""));

        out.close();
        System.exit(0);
    }

    int go(int mask) {
        if (mask == target) {
            return 0;
        }
        if (dp[mask] != -1) {
            return dp[mask];
        }

        ArrayList<Integer> notDone = getBits(mask, false);

        dp[mask] = Integer.MAX_VALUE;

        for (Integer i: notDone) {
            int oneD = (dist[i][25] << 1) + go(mask | pow[i]);
            if (dp[mask] > oneD) {
                dp[mask] = oneD;
                next[mask] = 1 << i;
            }
            for (Integer j: notDone) {
                if (j == i) continue;
                int d = (dist[j][25] + dist[i][j] + dist[i][25]) + go(mask | pow[i] | pow[j]);
                if (dp[mask] > d) {
                    dp[mask] = d;
                    next[mask] = (1 << i) | (1 << j);
                }
            }
            break;
        }

        return dp[mask];
    }

    int getDist(int[] p1, int[] p2) {
        return sq(p1[0] - p2[0]) + sq(p1[1] - p2[1]);
    }

    int sq(int a) {
        return a * a;
    }

    ArrayList<Integer> getBits(int mask, boolean on) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            if (((mask & (1 << i)) == 0) ^ on) {
                res.add(i);
            }
        }
        return res;
    }

    //The PandaScanner class, for Panda fast scanning!
    public class PandaScanner {
        BufferedReader br;
        StringTokenizer st;
        InputStream in;

        PandaScanner(InputStream in) throws Exception {
            br = new BufferedReader(new InputStreamReader(this.in = in));
        }

        public String next() throws Exception {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine().trim());
                return next();
            }
            return st.nextToken();
        }

        public boolean hasNext() throws Exception {
            return (st != null && st.hasMoreTokens()) || in.available() > 0;
        }

        public long nextLong() throws Exception {
            return Long.parseLong(next());
        }

        public int nextInt() throws Exception {
            return Integer.parseInt(next());
        }
    }
}


import static java.util.Arrays.*;
import static java.lang.Math.*;
import java.util.*;
import java.io.*;

public class Main implements Runnable
{
	public static void main(String [] args) throws IOException
	{
		new Thread(null, new Main(), "", 1 << 20).start();
	}

	String file = "input";
	BufferedReader input;
	PrintWriter out;

	public void run()
	{
		try
		{
			//input = new BufferedReader(new FileReader(file + ".in"));
			input = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new BufferedOutputStream(System.out));
			solve();
			input.close();
			out.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		}
	}
	int[] x = new int[25];
	int[] y = new int[25];
	int[][] dist = new int[25][25];
	int[] single = new int[25];
	int[] c = new int[25];
	int INF = 1 << 30;
	void solve() throws IOException
	{
		StringTokenizer st = tokens();
		x[0] = nextInt(st);
		y[0] = nextInt(st);
		int n = nextInt();
		for(int i = 1; i <= n; i++)
		{
			st = tokens();
			x[i] = nextInt(st);
			y[i] = nextInt(st);
		}
		for(int i = 1; i <= n; i++)
			single[i] = 2 * ((x[i] - x[0]) * (x[i] - x[0]) + (y[i] - y[0]) * (y[i] - y[0]));
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				dist[i][j] = single[i] / 2 + single[j] / 2 + (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
		int[] dp = new int[1 << n];
		int[] prev = new int[1 << n];
		fill(dp, INF);
		dp[0] = 0;
		for(int i = 1; i < 1 << n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				if((i >> j & 1) != 0)
				{
					if(dp[i] > dp[i ^ (1 << j)] + single[j + 1])
					{
						dp[i] = dp[i ^ (1 << j)] + single[j + 1];
						prev[i] = j + 1;
					}

					for(int k = j + 1; k < n; k++)
						if((i >> k & 1) != 0)
						{
							if(dp[i] > dp[i ^ (1 << j) ^ (1 << k)] + dist[j + 1][k + 1])
							{
								dp[i] = dp[i ^ (1 << j) ^ (1 << k)] + dist[j + 1][k + 1];
								prev[i] = (j + 1) * 100 + (k + 1);
							}
						}
					break;
				}
			}
		}
		out.println(dp[(1 << n) - 1]);
		out.print("0 ");
		int mask = (1 << n) - 1;
		while(mask > 0)
		{
			int s = prev[mask];
			int x = s / 100;
			int y = s % 100;
			if(x == 0)
			{
				out.print(y + " " + 0 + " ");
				mask -= 1 << (y - 1);
			}
			else
			{
				out.print(x + " " + y + " " + 0 + " ");
				mask -= 1 << (y - 1);
				mask -= 1 << (x - 1);
			}
		}
	}

	StringTokenizer tokens() throws IOException
	{
		return new StringTokenizer(input.readLine());
	}

	String next(StringTokenizer st)
	{
		return st.nextToken();
	}

	int nextInt() throws IOException
	{
		return Integer.parseInt(input.readLine());
	}

	int nextInt(StringTokenizer st)
	{
		return Integer.parseInt(st.nextToken());
	}

	double nextDouble() throws IOException
	{
		return Double.parseDouble(input.readLine());
	}

	double nextDouble(StringTokenizer st)
	{
		return Double.parseDouble(st.nextToken());
	}

	void print(Object... o)
	{
		out.println(deepToString(o));
	}
}


import java.io.*;
import java.util.*;

public class LookingForOrder
{
	public Scanner in = new Scanner(System.in);
	public PrintStream out = System.out;

	public int[] go;
	public int[][] cost;

	public int [] sol;
	public Pair[] how;
	public int n, lim;

	public Pair bag;
	public Pair[] obj;

	public void main()
	{
		bag = new Pair(in.nextInt(), in.nextInt());

		n = in.nextInt();
		obj = new Pair[n];
		for(int i=0;i<n;++i) obj[i] = new Pair(in.nextInt(), in.nextInt());

		go = new int[n];
		cost = new int[n][n];
		for(int i=0;i<n;++i)
		{
			go[i] = squDist(bag, obj[i]);
			for(int j=0;j<n;++j) cost[i][j] = squDist(obj[i], obj[j]);
		}

		lim = (1<<n);

		sol = new int[lim];
		Arrays.fill(sol, -1);
		how = new Pair[lim];

		out.println(solve(lim-1));

		Pair T;
		int set = lim-1;

		out.print("0");
		while(set > 0)
		{
			solve(set);
			T = how[set];
			out.print(" "+(T.x+1));
			set = off(T.x, set);
			if(T.y >= 0)
			{
				out.print(" " + (T.y+1));
				set = off(T.y, set);
			}
			out.print(" 0");
		}
		out.println();
	}//end public void main()

	public int oo = 987654321;

	public boolean in(int x, int set) { return ((1<<x) & set) != 0; }
	//Turn on bit x
	public int on(int x, int set) { return (set | (1<<x)); }
	//Turn off bit x
	public int off(int x, int set) { return (set ^ (set & (1<<x)) ); }

	public int solve(int set)
	{
		if(sol[set] >= 0) return sol[set];

		int ret;
		if(set == 0) ret = 0;
		else
		{
			ret = oo;

			int x, y, sub, c;
			for(x=0;x<n;++x) if(in(x, set)) break;

			sub = off(x, set);
			c =  go[x]+go[x]+solve(sub);

			if(c < ret)
			{
				how[set] = new Pair(x, -1);
				ret = c;
			}

			for(y=x+1;y<n;++y) if(in(y, set))
			{
				c = go[x]+cost[x][y]+go[y] + solve(off(y, sub));
				if(c < ret)
				{
					ret = c;
					how[set] = new Pair(x, y);
				}
			}
		}

		return sol[set] = ret;
	}

	public int squDist(int ax, int ay, int bx, int by)
	{
		int dx, dy;
		dx = ax - bx;
		dy = ay - by;
		return dx*dx + dy*dy;
	}

	public int squDist(Pair p, Pair q)
	{
		return squDist(p.x, p.y, q.x, q.y);
	}

	//int pair
	private class Pair implements Comparable<Pair>
	{
		public int x, y;
		public Pair(int xx, int yy) { x = xx; y = yy; }

		public int compareTo(Pair u)
		{
			if(x!=u.x) return x-u.x;
			return y-u.y;
		}

		public String toString() { return "(" + x + "," + y + ")"; }
	}

	public static void main(String[] args)
	{
		(new LookingForOrder()).main();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class LookingForOrder {
	static int[][] pos;
	static int[] dp;
	static int[] nextstate;
	static int[][] dist;
	static int r;
	static int v;

	static void print(int mask) {
		if (mask < v) {
			int c = 0;
			int x = mask ^ nextstate[mask];
			for (int i = 0; i < dist.length - 1; i++) {
				if((x & (1<<i))>0) {
					System.out.print(i+1 + " ");
					c++;
				}
			}
			System.out.print("0 ");
			print(nextstate[mask]);
		}
	}

	static int distace(int x1, int x2, int y1, int y2) {
		return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
	}

	static int solve(int mask) {
		if (mask == v) {
			nextstate[mask] = r;

			return 0;
		}
		if (nextstate[mask] != 0) {
			return dp[mask];
		}

		dp[mask] = (int) 1e9;
		for (int i = 1; i < pos.length; i++) {
			int u = (1 << (i - 1));
			int z = mask | u;
			if ((mask & u) == 0) {
				int x = 2 * dist[i][0] + solve(z);
				if (dp[mask] > x) {
					dp[mask] = x;
					nextstate[mask] = z;
				}

				for (int j = 1; j < pos.length; j++) {
					int m = (1 << j - 1);
					int y = z | m;
					if ((z & m) == 0) {
						x = dist[i][0] + solve(y) + dist[i][j] + dist[j][0];

						if (dp[mask] > x) {
							dp[mask] = x;
							nextstate[mask]= y;
						}

					}
				}
				break;
			}
		}
		return dp[mask];
	}

	public static void main(String[] args) {
		InputReader0 in = new InputReader0(System.in);
		int x = in.nextInt(), y = in.nextInt();
		int n = in.nextInt();
		r = 1 << n;
		v = r - 1;
		dp = new int[r];
		nextstate = new int[r];
		pos = new int[n + 1][2];
		pos[0][0] = x;
		pos[0][1] = y;
		for (int i = 1; i < pos.length; i++) {
			pos[i][0] = in.nextInt();
			pos[i][1] = in.nextInt();
		}
		dist = new int[n + 1][n + 1];
		for (int i = 0; i < dist.length; i++) {
			for (int j = i + 1; j < dist.length; j++) {
				dist[i][j] = dist[j][i] = distace(pos[i][0], pos[j][0], pos[i][1], pos[j][1]);
			}
		}

		System.out.println(solve(0));
		System.out.print("0 ");
		print(0);
	}

}

class InputReader0 {
	BufferedReader reader;
	StringTokenizer tokenizer;

	public InputReader0(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Bag implements Runnable {
    private void solve() throws IOException {
        int xs = nextInt();
        int ys = nextInt();
        int n = nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; ++i) {
            x[i] = nextInt();
            y[i] = nextInt();
        }
        int[][] pair = new int[n][n];
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j)
                pair[i][j] = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys) + (x[j] - xs) * (x[j] - xs) + (y[j] - ys) * (y[j] - ys) + (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
        int[] single = new int[n];
        for (int i = 0; i < n; ++i) {
            single[i] = 2 * ((x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys));
        }
        int[] best = new int[1 << n];
        int[] prev = new int[1 << n];
        for (int set = 1; set < (1 << n); ++set) {
            int i;
            for (i = 0; i < n; ++i)
                if ((set & (1 << i)) != 0)
                    break;
            best[set] = best[set ^ (1 << i)] + single[i];
            prev[set] = i + 1;
            for (int j = i + 1; j < n; ++j)
                if ((set & (1 << j)) != 0) {
                    int cur = best[set ^ (1 << i) ^ (1 << j)] + pair[i][j];
                    if (cur < best[set]) {
                        best[set] = cur;
                        prev[set] = (i + 1) * 100 + (j + 1);
                    }
                }
        }
        writer.println(best[(1 << n) - 1]);
        int now = (1 << n) - 1;
        writer.print("0");
        while (now > 0) {
            int what = prev[now];
            int wa = what % 100 - 1;
            int wb = what / 100 - 1;
            if (wa >= 0) {
                writer.print(" ");
                writer.print(wa + 1);
                now ^= 1 << wa;
            }
            if (wb >= 0) {
                writer.print(" ");
                writer.print(wb + 1);
                now ^= 1 << wb;
            }
            writer.print(" ");
            writer.print("0");
        }
        writer.println();
    }

    public static void main(String[] args) {
        new Bag().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.util.*;
import static java.lang.Math.*;

public class C {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		hx = sc.nextInt();
		hy = sc.nextInt();
		N = sc.nextInt();
		X = new int[N];
		Y = new int[N];
		for(int i = 0; i < N;i++){
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		DP = new int[1<<N];
		Arrays.fill(DP,-1);
		int ans = recur(0);
		ArrayList<Integer> aa = new ArrayList<Integer>();
		int U = 0;
		aa.add(0);
		int test = 0;
		while(U != (1<<N)-1){
			int a = 0;
			for(int i = 0; i < N;i++)
				if(((1<<i)&U) == 0){
					a = i;
					break;
				}
			int ans2 = recur(U|(1<<a))+2*(pw(X[a]-hx)+pw(Y[a]-hy));
			int temp = 2*(pw(X[a]-hx)+pw(Y[a]-hy));
			int best = -1;
			for(int i = a+1;i<N;i++){
				if(((1<<i)&U) == 0){
					int ans3 = pw(X[a]-X[i])+pw(Y[a]-Y[i])+pw(X[a]-hx)+pw(Y[a]-hy)+pw(X[i]-hx)+pw(Y[i]-hy)+recur(U|(1<<a)|(1<<i));
					if(ans3 < ans2){
						ans2 = ans3;
						best = i;
						temp = pw(X[a]-X[i])+pw(Y[a]-Y[i])+pw(X[a]-hx)+pw(Y[a]-hy)+pw(X[i]-hx)+pw(Y[i]-hy);
					}
				}
			}
			if(best == -1){
				aa.add(a+1);
				aa.add(0);
				U |= (1<<a);
			}else{
				aa.add(a+1);
				aa.add(best+1);
				aa.add(0);
				U |= (1<<a) | (1<<best);
			}
			test += temp;
		}
//		System.out.println(test);
		if(test != ans)
			throw new RuntimeException();
		System.out.println(ans);
		for(int i = 0; i < aa.size();i++)
			System.out.print(aa.get(i)+(i == aa.size()-1?"":" "));
		System.out.println();
	}
	private static int recur(int U) {
		if(DP[U] != -1)
			return DP[U];
		if(U == (1<<N)-1)
			return 0;
		int a = 0;
		for(int i = 0; i < N;i++)
			if(((1<<i)&U) == 0){
				a = i;
				break;
			}
		int ans = recur(U|(1<<a))+2*(pw(X[a]-hx)+pw(Y[a]-hy));
		for(int i = a+1;i<N;i++){
			if(((1<<i)&U) == 0){
				ans = min(ans,pw(X[a]-X[i])+pw(Y[a]-Y[i])+pw(X[a]-hx)+pw(Y[a]-hy)+pw(X[i]-hx)+pw(Y[i]-hy)+recur(U|(1<<a)|(1<<i)));
			}
		}
		DP[U] = ans;
		return ans;
	}
	static int pw(int a){
		return a*a;
	}
	static int hx,hy;
	static int[] X,Y;
	static int N;
	static int[] DP;
}


import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    int INF = Integer.MAX_VALUE >> 1;

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        /* Input */
        int x0 = nextInt();
        int y0 = nextInt();
        int N = nextInt();
        int FULL_MASK = (1 << N) - 1;
        int[] xs = new int [N];
        int[] ys = new int [N];
        for (int i = 0; i < N; i++) {
            xs[i] = nextInt();
            ys[i] = nextInt();
        }

        /* Precalc */
        int[][] dist = new int [N][N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                dist[i][j] = dist(x0, y0, xs[i], ys[i]) + dist(xs[i], ys[i], xs[j], ys[j]) + dist(xs[j], ys[j], x0, y0);

        /* DP */
        int[] dp = new int [1 << N];
        int[] pr = new int [1 << N];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int mask = 0; mask < FULL_MASK; mask++) {
            int i = Integer.numberOfTrailingZeros(~mask); // hack: use first non-zero bit
            int imask = mask | (1 << i);
            for (int j = i; j < N; j++) {
                int jmask = mask | (1 << j);
                if (jmask == mask) continue;
                int ijmask = imask | jmask;
                int nval = dp[mask] + dist[i][j];
                if (dp[ijmask] > nval) {
                    dp[ijmask] = nval;
                    pr[ijmask] = mask;
                }
            }
        }

        /* Output */
        out.println(dp[FULL_MASK]);
        out.print("0");
        for (int mask = FULL_MASK; mask != 0; mask = pr[mask]) {
            int diff = mask ^ pr[mask];
            int i = Integer.numberOfTrailingZeros(diff);
            diff &= ~(1 << i);
            int j = Integer.numberOfTrailingZeros(diff);
            if (i != 32) out.print(" " + (i + 1));
            if (j != 32) out.print(" " + (j + 1));
            out.print(" 0");
        }
        out.println();
        out.close();
    }

    /***************************************************************
     * Utility
     **************************************************************/
    int dist(int x1, int y1, int x2, int y2) {
        return sqr(x2 - x1) + sqr(y2 - y1);
    }

    int sqr(int x) {
        return x * x;
    }

    /***************************************************************
     * Input
     **************************************************************/
    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeD
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}
	}
	static final Scanner sc;
	static final int n;
	static final int[][] distancias;
	static final int[] distancia;
	static final int[] dp;
	static final int[] dpNext;
	static final int X;
	static final int Y;

	static
	{
		sc = new Scanner();
		X = sc.nextInt();
		Y = sc.nextInt();
		n = sc.nextInt();
		distancias = new int[n][n];
		distancia = new int[n];
		dp = new int[1 << n];
		Arrays.fill(dp, -1);
		dpNext = new int[1 << n];
	}

	static int dp(int mascara)
	{
		if(dp[mascara] != -1)
			return dp[mascara];
		int highest = -1;
		for(int i = 0, tmp = mascara; tmp != 0; i++, tmp >>= 1)
		{
			if((tmp & 1) == 1)
				highest = i;
		}
		if(highest == -1)
			return 0;
		int nextMsc = mascara ^ (1 << highest);
		int costHighest = distancia[highest];
		int best = (costHighest << 1) + dp(nextMsc);
		int bestNext = nextMsc;
		for(int i = 0, tmp = nextMsc, iC = 1; tmp != 0; i++, tmp >>= 1, iC <<= 1)
		{
			if((tmp & 1) == 1)
			{
				int msc = nextMsc ^ iC;
				int possibleA = costHighest + distancias[highest][i] + distancia[i] + dp(msc);
				if(possibleA < best)
				{
					best = possibleA;
					bestNext = msc;
				}
			}
		}
		dpNext[mascara] = bestNext;
		return dp[mascara] = best;

	}
	public static void main(String[] args)
	{
		int[][] objetos = new int[n][2];
		for(int i = 0; i < n; i++)
		{
			objetos[i][0] = sc.nextInt();
			objetos[i][1] = sc.nextInt();
			distancia[i] = (X - objetos[i][0]) * (X - objetos[i][0]) + (Y - objetos[i][1]) * (Y - objetos[i][1]);
		}
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				distancias[i][j] = (objetos[i][0] - objetos[j][0]) * (objetos[i][0] - objetos[j][0]) + (objetos[i][1] - objetos[j][1]) * (objetos[i][1] - objetos[j][1]);
		int ans = dp((1 << n) - 1);
		System.out.println(ans);
		int current = (1 << n) - 1;
		while(current != 0)
		{
			int next = dpNext[current];
			int differents = next ^ current;
			System.out.print("0 ");
			for(int i = 0; i < n; i++)
				if((differents & (1 << i)) != 0)
					System.out.print((i + 1) + " ");
			current = next;
		}
		System.out.println("0");
	}

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class _8C {

  static int[] x = new int[30], y = new int[30];
  static int[][] dist = new int[30][30];
  static int n;
  static final int M = 1000;
  static int[] bitPos = new int[M];
  static {
    Arrays.fill(bitPos, -1);
    for (int i=0; i<24; i++)
      bitPos[(1 << i) % M] = i;
  }

  static int sqr(int i) {
    return i * i;
  }

  public static void main(String[] args) throws Exception {
    Reader.init(System.in);
    BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out));

    x[0] = Reader.nextInt();
    y[0] = Reader.nextInt();
    n = Reader.nextInt();
    for (int i=1; i<=n; i++) {
      x[i] = Reader.nextInt();
      y[i] = Reader.nextInt();
    }
    for (int i=0; i<=n; i++)
      for (int j=0; j<=n; j++)
        dist[i][j] = sqr(x[i] - x[j]) + sqr(y[i] - y[j]);

    int[] f = new int[1 << n];
    int[] r = new int[1 << n];
    for (int mask=1; mask<(1 << n); mask++) {
      int lowbit = mask & -mask;
      int lowbitPos = bitPos[lowbit % M];
      f[mask] = dist[lowbitPos + 1][0] * 2 + f[mask ^ lowbit];
      r[mask] = lowbit;
        for (int i=mask^(lowbit); i>0; i=i^(i & -i)) {
          int otherBit = i & -i;
          int otherBitPos = bitPos[otherBit % M];
          int tmp = dist[0][lowbitPos + 1] + dist[lowbitPos + 1][otherBitPos + 1] + dist[otherBitPos + 1][0] + f[mask ^ otherBit ^ lowbit];
          if (tmp < f[mask]) {
            f[mask] = tmp;
            r[mask] = lowbit | otherBit;
          }
      }
    }

    System.out.println(f[(1 << n) - 1]);
    int mask = (1 << n) - 1;
    while(mask > 0) {
      if ((r[mask] ^ (r[mask] & -r[mask])) == 0) {
        System.out.print("0 " + (bitPos[r[mask] % M] + 1) + " ");
      }
      else {
        int bit1 = r[mask] & -r[mask];
        int bit2 = r[mask] ^ bit1;
        System.out.print("0 " + (bitPos[bit1 % M] + 1) + " " + (bitPos[bit2 % M] + 1) + " ");
      }
      mask ^= r[mask];
    }
    System.out.println("0");

    cout.close();
  }

  static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
    final U _1;
    final V _2;

    private Pair(U key, V val) {
      this._1 = key;
      this._2 = val;
    }

    public static <U extends Comparable<U>, V extends Comparable<V>> Pair<U, V> instanceOf(U _1, V _2) {
      return new Pair<U, V>(_1, _2);
    }

    @Override
    public String toString() {
      return _1 + " " + _2;
    }

    @Override
    public int hashCode() {
      int res = 17;
      res = res * 31 + _1.hashCode();
      res = res * 31 + _2.hashCode();
      return res;
    }

    @Override
    public int compareTo(Pair<U, V> that) {
      int res = this._1.compareTo(that._1);
      if (res < 0 || res > 0)
        return res;
      else
        return this._2.compareTo(that._2);
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj)
        return true;
      if (!(obj instanceof Pair))
        return false;
      Pair<?, ?> that = (Pair<?, ?>) obj;
      return _1.equals(that._1) && _2.equals(that._2);
    }
  }

  /** Class for buffered reading int and double values */
  static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
      reader = new BufferedReader(new InputStreamReader(input));
      tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
      while (!tokenizer.hasMoreTokens()) {
        // TODO add check for eof if necessary
        tokenizer = new StringTokenizer(reader.readLine());
      }
      return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
      return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }
  }

  static class ArrayUtil {
    static void swap(int[] a, int i, int j) {
      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }

    static void swap(long[] a, int i, int j) {
      long tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }

    static void swap(double[] a, int i, int j) {
      double tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }

    static void swap(char[] a, int i, int j) {
      char tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }

    static void swap(boolean[] a, int i, int j) {
      boolean tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }

    static void reverse(int[] a, int i, int j) {
      for (; i < j; i++, j--)
        swap(a, i, j);
    }

    static void reverse(long[] a, int i, int j) {
      for (; i < j; i++, j--)
        swap(a, i, j);
    }

    static void reverse(double[] a, int i, int j) {
      for (; i < j; i++, j--)
        swap(a, i, j);
    }

    static void reverse(char[] a, int i, int j) {
      for (; i < j; i++, j--)
        swap(a, i, j);
    }

    static void reverse(boolean[] a, int i, int j) {
      for (; i < j; i++, j--)
        swap(a, i, j);
    }

    static long sum(int[] a) {
      int sum = 0;
      for (int i : a)
        sum += i;
      return sum;
    }

    static long sum(long[] a) {
      long sum = 0;
      for (long i : a)
        sum += i;
      return sum;
    }

    static double sum(double[] a) {
      double sum = 0;
      for (double i : a)
        sum += i;
      return sum;
    }

    static int max(int[] a) {
      int max = Integer.MIN_VALUE;
      for (int i : a)
        if (i > max)
          max = i;
      return max;
    }

    static int min(int[] a) {
      int min = Integer.MAX_VALUE;
      for (int i : a)
        if (i < min)
          min = i;
      return min;
    }

    static long max(long[] a) {
      long max = Long.MIN_VALUE;
      for (long i : a)
        if (i > max)
          max = i;
      return max;
    }

    static long min(long[] a) {
      long min = Long.MAX_VALUE;
      for (long i : a)
        if (i < min)
          min = i;
      return min;
    }
  }
}


import java.util.*;
import java.lang.Math.*;

public class Main {
	static Scanner in = new Scanner(System.in);
	static Coor[] p;
	static Coor ori;
	static int n;
	static int dp[];
	static Coor pre[];
	public static void main(String[] args) {
		ori = new Coor(in.nextInt(),in.nextInt());
		n = in.nextInt();
		p = new Coor[n];
		dp = new int[1<<n];
		pre = new Coor[1<<n];
		for (int i = 0;i < n;i++) {
			p[i] = new Coor(in.nextInt(),in.nextInt());
		}
		Arrays.fill(dp,-1);
		dp[0] = 0;
		System.out.println( getdp((1<<n)-1));
		//System.out.printf("%d",0);
		System.out.printf("%d",0);
		trace((1<<n)-1);
		System.out.println();
	}
	static void trace(int mask) {
		if (mask == 0) return;
		if (pre[mask].y == -1) {
			System.out.printf(" %d %d",pre[mask].x+1,0);
			trace( mask - ( 1<< pre[mask].x ) );
		} else {
			System.out.printf(" %d %d %d",pre[mask].x+1,pre[mask].y+1,0);
			trace( mask - ( 1<< pre[mask].x ) - (1<<pre[mask].y));
		}
	}
	static int getdp(int mask) {
		if (dp[mask] != -1)
			return dp[mask];
		int fr = 0;
		for (int i = 0;i < n;i++)
			if ( (mask & (1 << i)) != 0 ) {
				fr = i;
				break;
			}
		dp[mask] = getdp( mask - (1 << fr) ) + 2 * p[fr].dist(ori);
		pre[mask] = new Coor(fr,-1);
		for (int i = fr+1;i < n;i++) {
			int to = i;
			if ( (mask & (1 << i)) != 0) {
				int tmp = getdp( mask - (1<<fr) - (1<<i) ) + p[fr].dist(ori) + p[to].dist(ori) + p[fr].dist(p[to]);
				if (tmp < dp[mask]) {
					dp[mask] = tmp;
					pre[mask].y = i;
				}
			}
		}
		return dp[mask];
	}
}

class Coor {
	int x,y;
	Coor(int _x,int _y) {
		x = _x;y = _y;
	}
	int dist(Coor o) {
		return ( (x-o.x) * (x-o.x) + (y-o.y) * (y-o.y) );
	}
}