Problem: Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, she wanted to put them back into her handbag. The problem is that the girl cannot carry more than two objects at a time, and cannot move the handbag. Also, if he has taken an object, she cannot put it anywhere except her handbag — her inherent sense of order does not let her do so.

You are given the coordinates of the handbag and the coordinates of the objects in some Сartesian coordinate system. It is known that the girl covers the distance between any two objects in the time equal to the squared length of the segment between the points of the objects. It is also known that initially the coordinates of the girl and the handbag are the same. You are asked to find such an order of actions, that the girl can put all the objects back into her handbag in a minimum time period.

Input

The first line of the input file contains the handbag's coordinates xs, ys. The second line contains number n (1 ≤ n ≤ 24) — the amount of objects the girl has. The following n lines contain the objects' coordinates. All the coordinates do not exceed 100 in absolute value. All the given positions are different. All the numbers are integer.

Output

In the first line output the only number — the minimum time the girl needs to put the objects into her handbag. 

In the second line output the possible optimum way for Lena. Each object in the input is described by its index number (from 1 to n), the handbag's point is described by number 0. The path should start and end in the handbag's point. If there are several optimal paths, print any of them. 

Examples

Input

0 0
2
1 1
-1 1


Output

8
0 1 2 0 


Input

1 1
3
4 3
3 4
0 0


Output

32
0 1 2 0 3 0 

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Created by Brandt Henslee on 2/24/2015.
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] parsedString;
        int objectNum = 0;
        int xStart=0;
        int yStart=0;

        parsedString = in.readLine().split(" ");
        xStart = Integer.parseInt(parsedString[0]);
        yStart = Integer.parseInt(parsedString[1]);
        objectNum = Integer.parseInt(in.readLine());

        int[] xLocs = new int[objectNum+1];
        int[] yLocs = new int[objectNum+1];
        int[] bitMasks = new int[1<<objectNum];
        Arrays.fill(bitMasks, -1);
        int[] previous = new int[1<<objectNum];

        xLocs[objectNum]=xStart;
        yLocs[objectNum]=yStart;
        for(int i=0; i<objectNum; i++){
            parsedString = in.readLine().split(" ");
            xLocs[i] = Integer.parseInt(parsedString[0]);
            yLocs[i] = Integer.parseInt(parsedString[1]);
        }

        //go through all pairs and find time requirement for each pair of objects
        //the entry at point [i][j] is equal to the time it takes to get from point i to point j
        int[][] times = new int[objectNum+1][objectNum+1];
        for(int i=0;i<=objectNum;i++){
            for(int j=0; j<=objectNum;j++){
                times[i][j] = times[j][i] = (xLocs[i]-xLocs[j])*(xLocs[i]-xLocs[j])+(yLocs[i]-yLocs[j])*(yLocs[i]-yLocs[j]);
            }
        }

        //each value in bitmasks represents the minimum time necessary to get
        //the unmasked bits
        //so bitmasks[5] (5=101) is the fastest time in which you can get
        //items 1 and 3
        bitMasks[0] = 0; //collecting zero objects takes 0 time
        //1<<n makes the n+1 position in the bit string = 1
        //1<<2 = 100
        for (int i=0; i<(1<<objectNum); i++){
            if(bitMasks[i]==-1) {

            }else{
                for(int j=0; j<objectNum; j++){
                    if(((1<<j)&i) == 0){ //if our current j object hasn't been picked up yet
                        int curState = (1<<j) | i; //ith state after picking up j object
                        int curTime = bitMasks[i] + 2*times[objectNum][j]; //time required to get object j from bag at state i

                        if(bitMasks[curState] == -1 || curTime < bitMasks[curState]){
                            bitMasks[curState] = curTime; //put fastest time in for gettingto our current state
                            previous[curState] = i;
                        }


                        for(int k=0; k<objectNum; k++){
                            if(((1<<k) & curState) == 0){ //if the kth position in our current state hasn't been picked up
                                int kState = ((1<<k) | curState); //curstate after picking pu kth object
                                //kTime is time it takes to go from bag, to j, to k and back
                                int kTime = bitMasks[i] + times[objectNum][j] + times[j][k] + times[k][objectNum];

                                if(bitMasks[kState] == -1 || kTime < bitMasks[kState]){
                                    bitMasks[kState] = kTime;  //put shortest tiem in for getting to kState
                                    previous[kState] = i;
                                }
                            }
                        }
                        break;
                    }
                }
            }

        }

        int finalState = (1<<objectNum)-1;

        System.out.println(bitMasks[finalState]);

        Deque<Integer> outputQ = new ArrayDeque<Integer>();
        outputQ.add(0);
        int curState = finalState;
        while(curState>0){
            //1100 ^ 1101 = 0001
            //difference is the objects picked up in this state but not in previous state
            int difference = curState ^ previous[curState];
            int firstItem = -1;
            int secondItem = -1;

            for(int i=0; i<objectNum; i++){
                if(((1<<i)&difference)>0){ //if the ith object was picked up in this state
                    secondItem=firstItem; //keep track of how many items are picked up
                    firstItem=i;
                }
            }

            if(secondItem!=-1){
                //put in two items followed by a return to 0

                outputQ.add(firstItem+1);
                outputQ.add(secondItem+1);
                outputQ.add(0);
            }
            else{
                outputQ.add(firstItem + 1);
                outputQ.add(0);
            }

            curState = previous[curState];
        }

        System.out.print(outputQ.removeLast());
        while(!outputQ.isEmpty()){
            System.out.print(" ");
            System.out.print(outputQ.removeLast());
        }
    }
}