import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * CodeForces 8C - Looking for Order
 * Created by Darren on 14-10-1.
 */
public class Main {
    Reader in = new Reader(System.in);
    PrintWriter out = new PrintWriter(System.out);

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

    int n;
    int[] x, y;
    int[][] time;
    int status;
    int[] dp;
    int[] pre;

    void run() throws IOException {
        int xs = in.nextInt(), ys = in.nextInt();
        n = in.nextInt();
        x = new int[n+1];
        y = new int[n+1];
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }
        x[n] = xs;
        y[n] = ys;

        computeTime();

        status = (1<<n);
        dp = new int[1<<n];
        pre = new int[1<<n];
        Arrays.fill(dp, -1);
        dp[0] = 0;
        for (int i = 0; i < status; i++) {
            if (dp[i] == -1)
                continue;
            for (int j = 0; j < n; j++) {
                if (((1<<j) & i) == 0) {
                    int t1 = ((1<<j) | i), temp1 = dp[i] + 2 * time[n][j];
                    if (dp[t1] == -1 || dp[t1] > temp1) {
                        dp[t1] = temp1;
                        pre[t1] = i;
                    }
                    for (int k = 0; k < n; k++) {
                        if (((1<<k) & t1) == 0) {
                            int t2 = ((1<<k) | t1),
                                    temp2 = dp[i] + time[n][j] + time[j][k] + time[k][n];
                            if (dp[t2] == -1 || dp[t2] > temp2) {
                                dp[t2] = temp2;
                                pre[t2] = i;
                            }
                        }
                    }
                    break;
                }
            }
        }

        int cur = (1 << n) - 1;
        out.println(dp[cur]);
        out.print(0);
        while (cur > 0) {
            int last = pre[cur], diff = cur ^ last;
            int obj1 = -1, obj2 = -1;
            for (int i = 0; i < n; i++) {
                if (((1<<i) & diff) > 0) {
                    obj2 = obj1;
                    obj1 = i;
                }
            }
            if (obj2 >= 0)
                out.printf(" %d %d %d", obj1+1, obj2+1, 0);
            else
                out.printf(" %d %d", obj1+1, 0);
            cur = last;
        }
        out.flush();
    }

    void computeTime() {
        time = new int[n+1][n+1];
        for (int i = 0; i <= n; i++) {
            for (int j = i+1; j <= n; j++)
                time[i][j] = time[j][i] = (x[i]- x[j])*(x[i]- x[j]) +
                        (y[i]- y[j])*(y[i]- y[j]);
        }
    }

    static class Reader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

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

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

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

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

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


import java.io.*;
import java.util.*;
public class AMain {
	static int n;
	static int[] best;
	static int[][] dist;
	static int[] home;
	static LinkedList<Integer> ret;
	public static void main(String[] args) throws IOException	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		State curr = new State(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
		n = Integer.parseInt(br.readLine());
		State[] list = new State[n];
		for(int i = 0; i < n; i++)	{
			st = new StringTokenizer(br.readLine());
			list[i] = new State(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
		}
		dist = new int[n][n];
		home = new int[n];
		for(int i = 0; i < n; i++)	{
			home[i] = dist(curr, list[i]);
		}
		for(int i = 0; i < n; i++)	{
			dist[i][i] = 2 * home[i];
			for(int j = i+1; j < n; j++)		{
				dist[i][j] = dist(list[i], list[j]) + home[i] + home[j];
			}
		}
		best = new int[1 << (n)];
		Arrays.fill(best, -1);
		best[0] = 0;
		System.out.println(solve(-1 + (1<<n)));
		ret = new LinkedList<Integer>();
		resolve(-1 + (1<<n));
		for(int x: ret)
			System.out.print(x + " ");
	}
	public static int dist(State a, State b)	{
		int x = a.x-b.x;
		int y = a.y-b.y;
		return x*x+y*y;
	}
	public static void resolve(int curr)	{
		ret.addLast(0);
		for(int i = 0; i < n; i++)	{
			if((curr & (1<<i)) == 0)
				continue;
			for(int j = i+1; j < n; j++)	{
				if((curr & (1 << j)) == 0)		{
					continue;
				}
				if(dist[i][j] + solve(curr ^ (1<<i) ^ (1 << j)) == best[curr])	{
					ret.addLast(i+1);
					ret.addLast(j+1);
					resolve(curr - (1<<i) - (1<<j));
					return;
				}
			}
			if(best[curr] == dist[i][i] + solve(curr ^ (1<<i)))	{
				ret.addLast(i+1);
				resolve(curr - (1<<i));
				return;
			}
		}
	}
	public static int solve(int curr)	{
		if(best[curr] != -1)
			return best[curr];
		int ret = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++)	{
			if((curr & (1<<i)) == 0)
				continue;
			for(int j = i+1; j < n; j++)	{
				if((curr & (1 << j)) == 0)		{
					continue;
				}
				ret = Math.min(ret, dist[i][j] + solve(curr ^ (1<<i) ^ (1 << j)));
			}
			ret = Math.min(ret, dist[i][i] + solve(curr ^ (1<<i)));
			break;
		}
		best[curr] = ret;
		return ret;
	}
	static class State	{
		public int x,y;
		public State(int a, int b)	{
			x=a;
			y=b;
		}
	}
}


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 C8 {
	static int[] mem;
	static int[] bag;
	static int[][] items;
	static int[] close;
	static PrintWriter pw;
	static int n;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);

		bag = new int[2];
		bag[0] = sc.nextInt();
		bag[1] = sc.nextInt();

		n = sc.nextInt();
		items = new int[n][2];

		for(int i = 0;i<n;i++)
		{
			items[i][0] = sc.nextInt();
			items[i][1] = sc.nextInt();
		}

		//System.out.println((items[0][1]-bag[1])*(items[0][1]-bag[1]));

		mem = new int[1<<n];

		Arrays.fill(mem, -1);

		pw.println(dp(0));
		trace(0);
		pw.print(0);

		pw.flush();
	}
	static int dp(int mask){
		if(mask==(1<<n)-1)
			return 0;

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

		int ans = (int)1e9;
		for(int i = 0;i<n;i++)
			if((1<<i&mask)==0)
			{
				ans = getDisBag(i)*2+dp(mask|1<<i);

				for(int j = i+1;j<n;j++)
					if((1<<j&mask)==0)
						ans = Math.min(ans, getDisBag(i)+getDis(i,j)+getDisBag(j)+dp(mask|1<<i|1<<j));

				break;
			}

		return mem[mask] = ans;
	}
	static int getDis(int i, int j){
		return (items[i][0]-items[j][0])*(items[i][0]-items[j][0])+(items[i][1]-items[j][1])*(items[i][1]-items[j][1]);
	}
	static int getDisBag(int i){
		return (items[i][0]-bag[0])*(items[i][0]-bag[0])+(items[i][1]-bag[1])*(items[i][1]-bag[1]);
	}
	static int getClosest(int i, int mask){
		int ret = -1;
		for(int j = 0;j<n;j++)
			if(i!=j&&(mask&1<<j)==0)
				if(ret==-1||getDis(i, j)<getDis(i, ret))
					ret = j;
		return ret;
	}
	static void trace(int mask){
		if(mask==(1<<n)-1)
			return;

		int ans = (int)1e9;
		for(int i = 0;i<n;i++)
			if((1<<i&mask)==0)
			{
				ans = getDisBag(i)*2+dp(mask|1<<i);
				if(mem[mask]==ans)
				{
					pw.print(0+" "+(i+1)+" ");
					trace(mask|1<<i);
					return;
				}

				for(int j = i+1;j<n;j++)
					if((1<<j&mask)==0)
						if(mem[mask] == getDisBag(i)+getDis(i,j)+getDisBag(j)+dp(mask|1<<i|1<<j))
						{
							pw.print(0+" "+(i+1)+" "+(j+1)+" ");
							trace(mask|1<<i|1<<j);
							return;
						}

			}

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		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 long nextLong() throws IOException {return Long.parseLong(next());}

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

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}
}


import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nguyen Trung Hieu - vuondenthanhcong11@yahoo.com
 */
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();
    }
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int xs = in.readInt();
        int ys = in.readInt();
        int n = in.readInt();
        int[] x = new int[n];
        int[] y = new int[n];
        IOUtils.readIntArrays(in, x, y);
        int[] res = new int[1 << n];
        int[] last = new int[1 << n];
        Arrays.fill(res, Integer.MAX_VALUE);
        int[] ds = new int[n];
        for (int i = 0; i < n; i++) {
            ds[i] = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys);
        }
        int[][] d = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++)
                d[i][j] = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
        }
        res[0] = 0;
        for (int i = 1; i < (1 << n); i++) {
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) != 0) {
                    if (res[i - (1 << j)] + 2 * ds[j] < res[i]) {
                        res[i] = res[i - (1 << j)] + 2 * ds[j];
                        last[i] = i - (1 << j);
                    }
                    for (int k = j + 1; k < n; k++) {
                        if (((i >> k) & 1) != 0) {
                            if (res[i - (1 << j) - (1 << k)] + ds[j] + ds[k] + d[j][k] < res[i]) {
                                res[i] = res[i - (1 << j) - (1 << k)] + ds[j] + ds[k] + d[j][k];
                                last[i] = i - (1 << j) - (1 << k);
                            }
                        }
                    }
                    break;
                }
            }
        }
        int cur = (1 << n) - 1;
        out.printLine(res[cur]);
        while (cur != 0) {
            out.print("0 ");
            int dif = cur - last[cur];
            for (int i = 0; i < n && dif != 0; i++) {
                if (((dif >> i) & 1) != 0) {
                    out.print((i + 1) + " ");
                    dif -= (1 << i);
                }
            }
            cur = last[cur];
        }
        out.printLine("0");
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private 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 c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

    }

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(Object...objects) {
        print(objects);
        writer.println();
    }

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

}

class IOUtils {

    public static void readIntArrays(InputReader in, int[]... arrays) {
        for (int i = 0; i < arrays[0].length; i++) {
            for (int j = 0; j < arrays.length; j++)
                arrays[j][i] = in.readInt();
        }
    }

    }


import java.util.*;

import static java.lang.System.out;

public final class LookingForOrder {
    private static Map<Integer, Integer> es = new HashMap<Integer, Integer>();
    private static void init() { for (int i = 0; i <= 24; i++) es.put(1 << i, i); }
    private static int x, y;
    private static int[] xs, ys;
    private static int sqr(int i) { return i * i; }
    private static int dist(int i, int j) {
        return sqr(x - xs[i]) + sqr(y - ys[i]) +
            sqr(xs[i] - xs[j]) + sqr(ys[i] - ys[j]) +
            sqr(x - xs[j]) + sqr(y - ys[j]);
    }

    private static int n;
    private static int[] tb, prevs;

    private static int recur(int j) {
        if (j == 0 || es.get(j) != null || tb[j] != 0) return tb[j];

        int bl = j & -j;
        int b = j ^ bl;
        tb[j] = recur(bl) + recur(b);
        prevs[j] = bl;

        for (int i = es.get(bl) + 1; i <25; i++) {
            if (((1 << i) & b) == 0) continue;

            int k = bl | 1 << i;
            int v = dist(es.get(bl), es.get(1 << i)) + recur(j ^ k);
            if (v >= tb[j]) continue;

            tb[j] = v;
            prevs[j] = k;
        }
        return tb[j];
    }

    public static void main(String[] args) {
        init();
        Scanner s = new Scanner(System.in);
        x = s.nextInt(); y = s.nextInt();
        n = s.nextInt();
        xs = new int[n]; ys = new int[n];
        tb = new int[1 << n]; prevs = new int[1 << n];

        for (int i = 0; i < n; i++) {
            xs[i] = s.nextInt(); ys[i] = s.nextInt();
            tb[1 << i] = sqr(x - xs[i]) + sqr(y - ys[i]) << 1;
        }

        int all = (1 << n) - 1;
        out.println(recur(all));
        StringBuilder sb = new StringBuilder();
        int p = prevs[all];
        int c = all;
        while(p != 0 && p != c) {
            if ((p ^ (p & -p)) == 0) sb.append("0 " + (es.get(p & -p) + 1) + " ");
            else sb.append("0 " + (es.get(p & -p) + 1) + " " + (es.get(p ^ (p & -p)) + 1) + " ");
            c = c ^ p;
            p = prevs[c];
        }

        if ((c ^ (c & -c)) == 0) sb.append("0 " + (es.get(c & -c) + 1) + " 0");
        else sb.append("0 " + (es.get(c & -c) + 1) + " " + (es.get(c ^ (c & -c)) + 1) + " 0");
        out.println(sb);
    }
}


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

/**
 * Created by James on 1/29/2015.
 */
public class Driver {
    private static int [][] distances, parents;
    private static int [] distance, parent;
    private static String [][] longNames;
    private static String [] shortNames, answers;
    private static int N;

    public static void main(String [] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));

        String [] pieces = scanner.readLine().split("\\s+");

        //totally had to steal the vast majority of this from http://codeforces.com/contest/8/submission/9745593

        Point origin = new Point(Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1]));

        N = Integer.parseInt(scanner.readLine());

        Point [] points = new Point[N + 1];
        distances = new int[N  + 1][N + 1];
        parents = new int[N + 1][N + 1];
        longNames = new String[N][N];
        shortNames = new String[N];

        for (int i = 0; i < N; ++i) {
            pieces = scanner.readLine().split("\\s+");

            points[i] = new Point(Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1]));
        }

        points[N] = origin;

        for (int i = 0; i <= N; ++i) {
            if (i < N) {
                shortNames[i] = (i + 1) + " ";
            }

            for (int j = 0; j <= N; ++j) {
                if (i < N && j < N) {
                    longNames[i][j] = (i + 1) + " " + (j + 1) + " ";
                }

                distances[i][j] = 2 * points[i].distance(points[j]);
                parents[i][j] = points[i].distance(points[N]) + points[i].distance(points[j]) + points[j].distance(points[N]);
            }
        }

        distance = new int[1 << N];
        parent = new int[1 << N];
        answers = new String[1 << N];
        Arrays.fill(distance, -1);
        distance[0] = 0;

        int result = rec((1 << N) - 1);
        StringBuilder answer = new StringBuilder();

        for (int i = distance.length - 1; parent[i] != i; i = parent[i]) {
            answer.append("0 ");
            answer.append(answers[i]);
        }

        answer.append("0");
        System.out.println(result);
        System.out.println(answer.toString());
    }

    private static int rec(int mask) {
        if (distance[mask] != -1) {
            return distance[mask];
        }

        int min = 0;

        while (((1 << min) & mask) == 0) {
            min++;
        }

        int newMask = mask & (~(1 << min));
        distance[mask] = rec(newMask) + distances[min][N];
        parent[mask] = newMask;
        answers[mask] = shortNames[min];

        for (int i = min + 1; i < N; i++) {
            if (((1 << i) & mask) > 0) {
                newMask = mask & (~(1 << i)) & (~(1 << min));

                int temp = rec(newMask) + parents[i][min];

                if (temp< distance[mask]) {
                    distance[mask] = temp;
                    parent[mask] = newMask;
                    answers[mask] = longNames[min][i];
                }
            }
        }

        return distance[mask];
    }

    private static class Point {
        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int distance(Point p) {
            return (int)(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
        }
    }
}


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

public class Solution implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    int[] x;
    int[] y;
    int n;
    int X, Y;

    int[] d;
    int[][] dist;

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

    int dist(int X, int Y, int i) {
        return sqr(X - x[i]) + sqr(Y - y[i]);
    }

    int[] dp;
    byte[][] pred;

    int rec(int mask) {
        if (dp[mask] == -1) {
            int res = 1 << 29;
            boolean ok = false;
            for (int i = 0; i < n; ++i)
                if ((mask & (1 << i)) > 0) {
                    ok = true;
                    int mm = mask & ~(1 << i);
                    for (int j = i; j < n; j++)
                        if ((mask & (1 << j)) > 0) {
                            int nmask = mm & ~(1 << j);
                            int a = rec(nmask) + d[i] + d[j] + dist[i][j];
                            if (a < res) {
                                res = a;
                                pred[0][mask] = (byte) (i);
                                pred[1][mask] = (byte) (j);
                            }
                        }
                    break;
                }
            if (!ok)
                res = 0;
            dp[mask] = res;
        }
        return dp[mask];
    }

    void solve() throws IOException {
        X = ni();
        Y = ni();
        n = ni();
        // if (n > 5)
        // return;
        x = new int[n];
        y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = ni();
            y[i] = ni();
        }
        d = new int[n];
        dist = new int[n][n];
        for (int i = 0; i < n; ++i)
            d[i] = dist(X, Y, i);
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; j++) {
                dist[i][j] = dist(x[i], y[i], j);
            }
        pred = new byte[2][1 << n];
        dp = new int[1 << n];
        Arrays.fill(dp, -1);
        out.println(rec((1 << n) - 1));
        int a = (1 << n) - 1;
        while (a > 0) {
            if (pred[0][a] != pred[1][a])
                out.print(0 + " " + (pred[0][a] + 1) + " " + (pred[1][a] + 1)
                        + " ");
            else
                out.print(0 + " " + (pred[0][a] + 1) + " ");
            int na = a & ~(1 << pred[0][a]);
            na &= ~(1 << pred[1][a]);
            a = na;
        }
        out.println(0);
    }

    public Solution() throws IOException {
        Locale.setDefault(Locale.US);
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

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

    int ni() throws IOException {
        return Integer.valueOf(ns());
    }

    long nl() throws IOException {
        return Long.valueOf(ns());
    }

    double nd() throws IOException {
        return Double.valueOf(ns());
    }

    public static void main(String[] args) throws IOException,
            InterruptedException {
        Thread th = new Thread(null, new Solution(), "", 536870912);
        th.start();
        th.join();
    }

    @Override
    public void run() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}


/**
 * DA-IICT
 * Author : PARTH PATEL
 */
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class C8
{

	public static long mod = 1000000007;
	public static long INF = (1L << 60);
	static FastScanner2 in = new FastScanner2();
	static OutputWriter out = new OutputWriter(System.out);
	static int n;
	static int x,y;
	static int[] xx;
	static int[] yy;
	static int[] dist;
	static int[][] g;
	static int[] dp;
	public static int square(int x)
	{
		return abs(x*x);
	}
	static class Pair
	{
		int x,y;
		Pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}
	}
	public static void main(String[] args)
	{

		x=in.nextInt();
		y=in.nextInt();
		n=in.nextInt();
		xx=new int[n];
		yy=new int[n];
		dp=new int[1<<n];
		for(int i=0;i<n;i++)
		{
			xx[i]=in.nextInt();
			yy[i]=in.nextInt();
		}
		dist=new int[n];
		g=new int[n][n];
		for(int i=0;i<n;i++)
		{
			dist[i]=square(abs(xx[i]-x))+square(abs(yy[i]-y));
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				g[i][j]=square(abs(xx[i]-xx[j]))+square(yy[i]-yy[j]);
				//System.out.println("i "+i+" j "+j+" "+g[i][j]);
			}
		}
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0]=0;
		for(int i=0;i<(1<<n);i++)
		{
			//we have to find dp[i]
			for(int j=0;j<n;j++)
			{
				if((i&(1<<j))>0)   //not visited j
				continue;
				dp[i|(1<<j)]=min(dp[i|(1<<j)], dp[i]+2*dist[j]);
				for(int k=j+1;k<n;k++)
				{
					if((i&(1<<k))>0)
						continue;
					dp[i|(1<<j)|(1<<k)]=min(dp[i|(1<<j)|(1<<k)], dp[i]+dist[j]+dist[k]+g[j][k]);
				}
				break;
			}
		}
		out.println(dp[(1<<n)-1]);
		Stack<Integer> stack=new Stack<>();
		stack.push(0);
		int i=(1<<n)-1;
		while(i>0)
		{
			boolean tocontinue=false;
			for(int a=0;a<n;a++)
			{
				if((i&(1<<a))==0)
					continue;
				if(dp[i]==(dp[i^(1<<a)]+2*dist[a]))
				{
					stack.push(a+1);
					stack.push(0);
					i-=(1<<a);
					tocontinue=true;
				}
				if(tocontinue)
					continue;
				for(int b=a+1;b<n;b++)
				{
					if((i & (1<<b)) == 0) continue;
					if(dp[i]==(dp[i^(1<<a)^(1<<b)]+dist[a]+dist[b]+g[a][b]))
					{
						i-=(1<<a);
						i-=(1<<b);
						stack.push(a+1);
						stack.push(b+1);
						stack.push(0);
						tocontinue=true;
					}
					if(tocontinue)
						break;
				}
				if(tocontinue)
					break;
			}

		}
		for(int ii : stack)
			out.print(ii+" ");
		out.close();

	}

	public static long pow(long x, long n, long mod)
	{
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod)
		{
			if ((n & 1) != 0)
			{
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2)
	{
		long r;
		while (n2 != 0)
		{
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	public static long lcm(long n1, long n2)
	{
		long answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}

	static class FastScanner2
	{
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

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

		public String nextLine()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long 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 int nextInt()
		{
			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 int[] nextIntArray(int n)
		{
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
			{
				arr[i] = nextInt();
			}
			return arr;
		}

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

		private boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}
	}

	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream)
		{
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

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

		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[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

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

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

	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 println(Object... objects)
		{
			print(objects);
			writer.println();
		}

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

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

}


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

public class LookingForOrder {

	static int[] x, y;
	static int[] dp;
	static int n;

	static int dist(int i, int j) {
		return ((x[i] - x[j]) * (x[i] - x[j]))
				+ ((y[i] - y[j]) * (y[i] - y[j]));
	}

	static int solve(int mask) {
		if (mask == (1 << n) - 1)
			return 0;
		if (dp[mask] != -1)
			return dp[mask];
		int ans = Integer.MAX_VALUE;
		int j = 0;
		for (int i = 1; i < n; i++)
			if ((mask & (1 << i)) == 0) {
				if (j == 0) {
					ans = Math
							.min(ans, 2 * dist(0, i) + solve(mask | (1 << i)));
					j = i;
				} else
					ans = Math.min(ans, dist(0, i) + dist(i, j) + dist(j, 0)
							+ solve(mask | (1 << i) | (1 << j)));
			}
		return dp[mask] = ans;
	}

	static void prnt(int mask) {
		if (mask == (1 << n) - 1)
			return;
		int j = 0;
		for (int i = 1; i < n; i++)
			if ((mask & (1 << i)) == 0) {
				if (j == 0) {
					j = i;
					if (dp[mask] == 2 * dist(0, i) + solve(mask | (1 << i))) {
						out.print(" " + i + " 0");
						prnt(mask | (1 << i));
						return;
					}
				} else if (dp[mask] == dist(0, i) + dist(i, j) + dist(j, 0)
						+ solve(mask | (1 << i) | (1 << j))) {
					out.print(" " + i + " " + j + " 0");
					prnt(mask | (1 << i) | (1 << j));
					return;
				}
			}
	}

	public static void main(String[] args) throws IOException {
		sc = new StringTokenizer(br.readLine());
		int a = nxtInt();
		int b = nxtInt();
		n = nxtInt() + 1;
		x = new int[n];
		y = new int[n];
		dp = new int[1 << n];
		Arrays.fill(dp, -1);
		x[0] = a;
		y[0] = b;
		for (int i = 1; i < n; i++) {
			x[i] = nxtInt();
			y[i] = nxtInt();
		}
		out.println(solve(1 << 0));
		out.print(0);
		prnt(1 << 0);
		out.println();
		br.close();
		out.close();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	static PrintWriter out = new PrintWriter(System.out);

	static StringTokenizer sc;

	static String nxtTok() throws IOException {
		while (!sc.hasMoreTokens())
			sc = new StringTokenizer(br.readLine());
		return sc.nextToken();
	}

	static int nxtInt() throws IOException {
		return Integer.parseInt(nxtTok());
	}

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}
}


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

public class LookingForOrder {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int bx = in.nextInt();
        int by = in.nextInt();
        in.nextLine();
        int n = in.nextInt();
        int[][] objects = new int[n][2];
        for (int i = 0; i < n; i++) {
            objects[i][0] = in.nextInt();
            objects[i][1] = in.nextInt();
        }

        int[] cs = new int[n];
        for (int i = 0; i < n; i++) {
            cs[i] = 2 * time(objects[i], new int[] { bx, by });
        }

        int[][] cd = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                cd[j][i] = cd[i][j] = time(objects[i], new int[] { bx, by }) + time(objects[j], new int[] { bx, by }) + time(objects[i], objects[j]);
            }
        }

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

        for (int g = 1; g < maxMask; g++) {
            int min = Integer.MAX_VALUE;
            int minPath = 0;
            int h = 31;
            while ((g & (1 << h)) == 0)
                h--;
            h++;
            int l = 0;
            while ((g & (1 << l)) == 0)
                l++;
            if ((g & 1 << l) > 0) {
                int oneleft = g ^ (1 << l);
                int t = cs[l] + dp[oneleft];
                if (t < min) {
                    min = t;
                    minPath = oneleft;
                }
                for (int j = l + 1; j < h; j++) {
                    if ((oneleft & 1 << j) > 0) {
                        int twoleft = oneleft ^ (1 << j);
                        t = cd[l][j] + dp[twoleft];
                        if (t < min) {
                            min = t;
                            minPath = twoleft;
                        }
                    }
                }
            }
            dp[g] = min;
            path[g] = minPath;
        }

        System.out.println(dp[maxMask - 1]);

        int previous = maxMask - 1;
        int pathElt = path[previous];
        System.out.print("0 ");
        while (previous > 0) {
            int bits = previous - pathElt;
            int h = 31;
            while ((bits & (1 << h)) == 0)
                h--;
            int l = 0;
            while ((bits & (1 << l)) == 0)
                l++;
            String el = h == l ? "" + (h + 1) : (h + 1) + " " + (l + 1);
            System.out.print(el + " " + 0 + " ");
            previous = pathElt;
            pathElt = path[pathElt];
        }
        System.out.println();

    }

    static int time(int[] a, int[] b) {
        int x = b[0] - a[0];
        int y = b[1] - a[1];
        return x * x + y * y;
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.awt.Point;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            Point bag = new Point(in.ni(), in.ni());
            int n = in.ni();
            Point[] arr = new Point[n];
            for (int i = 0; i < n; ++i)
                arr[i] = new Point(in.ni(), in.ni());
            int[] dist = new int[n];
            for (int i = 0; i < n; ++i) {
                int dx = arr[i].x - bag.x;
                int dy = arr[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 = arr[i].x - arr[j].x;
                    int dy = arr[i].y - arr[j].y;
                    d[i][j] = dx * dx + dy * dy + dist[i] + dist[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);
        }

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

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String n() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(n());
        }

    }
}


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

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

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

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

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

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

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

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

	private static void build(int msk) {
		if (msk == (1 << n) - 1)
			return;
		boolean foundFirst = false;
		int ans = dp(msk);
		int mark = -1;
		int val = (int)1e9;
		for (int i = 1; i <= n; i++) {
			if ((msk & 1 << (i - 1)) == 0){
				if(!foundFirst){
					foundFirst = true;
					mark = i;
					val = dist(0, mark)*2 + dp(msk | 1 << (mark - 1));
					if(val == ans){
						sb.append(mark + " 0 ");
						build(msk | 1 << (mark - 1));
						return;
					}
				}else{
					val = dist(0, mark) + dist(mark, i) + dist(i, 0) + dp(msk|1 << (mark - 1)|1 << (i - 1));
					if(val == ans){
						sb.append(mark + " " + i + " 0 ");
						build(msk|1 << (mark - 1)|1 << (i - 1));
						return;
					}
				}
			}
		}
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public MyScanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		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 long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;
/**
 * 9:50 ~
 *
 */
public class Main {
	public static int n, x, y;
	public static int[] a,b;
	public static int dp[], before[];
	public static int dx[];
	public static int d[][];
	public static final int INF = 24 * 201 * 201;
	public static void main(String[] argv) {
		FastScanner scan = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		x = scan.nextInt();
		y = scan.nextInt();

		n = scan.nextInt();

		a = new int[n+1];
		b = new int[n+1];
		dx = new int[n+1];
		d = new int[n+1][n+1];
		for(int i = 0; i < n; ++i){
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}

		for(int i = 0; i < n; ++i){
			dx[i] = dist(i);
		}
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				d[i][j] = dist(i,j);
			}
		}

		dp = new int[1 << n];
		before = new int[1 << n];
		Arrays.fill(dp, INF);
		dp[0] = 0;
		for(int state = 0; state < (1<<n); state++){
			//if(dp[state] == INF) continue;
			for(int i = 0; i < n; ++i){
				int ii = (1 << i);
				if((state & ii) > 0){
					if(dp[state - ii] == INF) continue;
					int newdist = dp[state - ii] + dx[i] + dx[i];
					if(dp[state] > newdist){
						dp[state] = newdist;
						before[state] = state - ii;
					}

				} else continue;

				for(int j = i + 1; j < n; ++j){
					if(i == j) continue;
					int jj = (1 << j);
					if((state & jj) > 0){
						if(dp[state - ii - jj] == INF) continue;
						int newdist = dp[state - ii - jj] + dx[i] + d[i][j] + dx[j];
						if(dp[state] > newdist){
							dp[state] = newdist;
							before[state] = state - ii - jj;
						}

					}
				}
				break;
			}
		}

		System.out.println(dp[(1<<n)-1]);
		int state = (1<<n) - 1;
		StringBuffer ret = new StringBuffer();
		while(state > 0){
			int nstate = before[state];
			boolean find = false;
			String made = "";
			for(int i = 0; i < n; ++i){
				if(((state & (1<<i)) > 0) && ((nstate & (1<<i)) == 0)){
					find = true;
					made = made + " " + (i + 1);
				}
			}
			if(find){
				made = made + " 0";
				ret.append(made, 0, made.length());
			}
			state = nstate;
		}
		out.println("0" + ret.toString());
		out.close();
	}
	public static int dist(int to){
		return Math.abs(a[to] - x) * Math.abs(a[to] - x) + Math.abs(b[to] - y) * Math.abs(b[to] - y);
	}
	public static int dist(int from, int to){
		return Math.abs(a[from]-a[to]) * Math.abs(a[from]-a[to]) + Math.abs(b[from]-b[to]) * Math.abs(b[from]-b[to]);
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream is) {
			try {
				br = new BufferedReader(new InputStreamReader(is));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

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

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

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

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


import java.util.Scanner;

public class CF_8C {

	public static void main(String[] args) {

		// Hooray bitmasks! I'm good at these :)

		Scanner in = new Scanner(System.in);

		// Handbag coordinates..
		int hb_x = in.nextInt(), hb_y = in.nextInt();
		int n = in.nextInt();
		int[] ox = new int[n];
		int[] oy = new int[n];

		// Dynamic programming: Also store a matrix of the time to reach one
		//  object from the other.
		// This considers the handbag to be object 0
		int[][] dt = new int[n][n];
		int[] hbd = new int[n];
		for (int i = 0; i < n; i++) {
			ox[i] = in.nextInt();
			oy[i] = in.nextInt();
			hbd[i] = (ox[i] - hb_x) * (ox[i] - hb_x)
					+ (oy[i] - hb_y) * (oy[i] - hb_y);
		}

		// Compute elapsed times...
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dt[i][j] = (ox[i] - ox[j]) * (ox[i] - ox[j])
						+ (oy[i] - oy[j]) * (oy[i] - oy[j]);
			}
		}

		// Fill up an array with the amount of time it takes to grab
		//  all objects with the specified bitmask.
		int[] sofar = new int[1 << n];
		int[] masks = new int[1 << n];
		sofar[0] = 0;
		for (int i = 1; i < (1 << n); i++) {
			sofar[i] = -1;
		}

		for (int i = 0; i < (1 << n); i++) {
			if (sofar[i] != -1) {
				for (int maskbit = 0; maskbit < n; maskbit++) {
					// Look for first object in bitmask to grab...
					if (((1 << maskbit) & i) == 0) {
						int iffirst = ((1 << maskbit) | i);
						int fromold = sofar[i] + 2 * hbd[maskbit];

						if (sofar[iffirst] == -1 || sofar[iffirst] > fromold) {
							// A better way to get to position J was found, use it.
							sofar[iffirst] = fromold;
							masks[iffirst] = i;
						}

						// Find another thing while you're out...
						for (int otherone = 0; otherone < n; otherone++) {
							if (((1 << otherone) & iffirst) == 0) {
								int iffollow = ((1 << otherone) | iffirst);
								int fromi = sofar[i] + hbd[maskbit] + dt[maskbit][otherone] + hbd[otherone];

								// Did we find a better way to get to iffollow state?
								if (sofar[iffollow] == -1 || sofar[iffollow] > fromi) {
									sofar[iffollow] = fromi;
									masks[iffollow] = i;
								}
							}
						}
						break;
					}
				}
			}
		}

		// After all this time, we have an answer.
		// The minimum time will be the value of sofar at the very end,
		//  which will have the case of if all objects were picked up.
		// Clever, no?
		// The logic came from http://www.darrensun.com/codeforces-round-8/
		// Wish I could claim it mine, but it is not so.

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

		System.out.println(sofar[end_val]);
		System.out.print(0);
		while (end_val > 0) {
			// Which objects were collected in the prvious trip?
			int diff = end_val ^ masks[end_val];
			int obj1 = -1, obj2 = -1;
			for (int i = 0; i < n; i++) {
				if (((1 << i) & diff) > 0) {
					obj2 = obj1;
					obj1 = i;
				}
			}

			if (obj2 >= 0) {
				// Two objects were collected this trip, output them both.
				System.out.print(" " + (obj1 + 1) + " " + (obj2 + 1) + " 0");
			} else {
				// Only one object was collected here.
				System.out.print(" " + (obj1 + 1) + " 0");
			}
			end_val = masks[end_val];
		}

		in.close();
	}

}


import java.util.*;
import java.awt.Polygon;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.*;
import java.util.Collection;

public class Solution {

	/**
	 * @param args
	 * @throws IOException
	 */
	static StringTokenizer st;
	static BufferedReader reader;
	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
		int xs = NextInt();
		int ys = NextInt();
		int n = NextInt();

		int x[] = new int[n];
		int y[] = new int[n];
		int single[] = new int[n];
		int pair[][] = new int[n][n];
		for (int i = 0; i < n; ++i) {
			x[i] = NextInt();
			y[i] = NextInt();
		}
		for (int i = 0; i < n; ++i)
			single[i] = 2 * dist(xs, ys, x[i], y[i]);
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				pair[i][j] = dist(xs, ys, x[i], y[i]) +
							 dist(x[i], y[i], x[j], y[j]) +
							 dist(x[j], y[j], xs, ys);
		int dp[] = new int[1 << n];
		int prev[] = new int[1 << n];
		for (int mask = 0; mask < (1 << n); ++mask) {
			int p = -1;
			for (int i = 0; i < n; ++i)
				if (((mask >> i) & 1) != 0) {
					p = i;
					break;
				}
			if (p == -1) continue;
			dp[mask] = dp[mask ^ (1 << p)] + single[p];
			prev[mask] = p;
			for (int j = p + 1; j < n; ++j) {
				if (((mask >> j) & 1) != 0) {
					int res = pair[p][j] + dp[mask ^ (1 << p) ^ (1 << j)];
					if (res < dp[mask]) {
						dp[mask] = res;
						prev[mask] = p + 100 * j;
					}
				}
			}
		}
		int cur = (1 << n) - 1;
		System.out.printf("%d\n0 ", dp[cur]);
		while(cur != 0) {
			if (prev[cur] < 100) {
				System.out.printf("%d %d ", prev[cur] + 1, 0);
				cur ^= (1 << prev[cur]);
			} else {
				int i = prev[cur] / 100;
				int j = prev[cur] % 100;
				System.out.printf("%d %d %d ", i + 1, j + 1, 0);
				cur = cur ^ (1 << i) ^ (1 << j);
			}
		}
	}
	static int dist(int x0, int y0, int x1, int y1) {
		return (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1);
	}
	static int NextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(NextToken());
	}
	static String NextToken() throws IOException {
		while(st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(reader.readLine());
		}
		return st.nextToken();
	}

}


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

public class Main {

    static final int MAXN = 24;
    int[] x = new int[MAXN];
    int[] y = new int[MAXN];
    int[][] dist = new int[MAXN][MAXN];
    int[] single = new int[MAXN];

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

    void run(int nT) {
        int xs = cin.nextInt();
        int ys = cin.nextInt();
        int n = cin.nextInt();
        for (int i = 0; i < n; ++i) {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();
        }
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                dist[i][j] = sqr(x[i] - xs) + sqr(y[i] - ys)
                    + sqr(x[i] - x[j]) + sqr(y[i] - y[j]) + sqr(x[j] - xs) + sqr(y[j] - ys);
            }
        }
        for (int i = 0; i < n; ++i) {
            single[i] = (sqr(x[i] - xs) + sqr(y[i] - ys)) * 2;
        }
        int[] dp = new int[1 << n];
        int[] pre = new int[1 << n];
        int tot = 1 << n;
        for (int s = 1; s < tot; ++s) {
            int i;
            for (i = 0; i < n; ++i) {
                if ((s & (1 << i)) != 0) break;
            }
            dp[s] = dp[s^(1<<i)] + single[i];
            pre[s] = i + 1;
            for (int j = i + 1; j < n; ++j) {
                if ((s & (1 << j)) != 0) {
                    int cur = dp[s^(1 << i) ^(1<<j)] + dist[i][j];
                    if (cur < dp[s]) {
                        dp[s] = cur;
                        pre[s] = (i + 1) * 100 + (j + 1);
                    }
                }
            }
        }
        out.println(dp[tot - 1]);
        int now = tot - 1;
        out.print("0");
        while (now > 0) {
            int what = pre[now];
            int px = what % 100 - 1;
            int py = what / 100 - 1;
            if (px >= 0) {
                out.print(" ");
                out.print(px + 1);
                now ^= 1 << px;
            }
            if (py >= 0) {
                out.print(" ");
                out.print(py + 1);
                now ^= 1 << py;
            }
            out.print(" ");
            out.print("0");
        }
        out.println("");
    }

    public static void main(String[] argv) {
        Main solved = new Main();
        int T = 1;
        // T = solved.cin.nextInt();
        for (int nT = 1; nT <= T; ++nT) {
            solved.run(nT);
        }
        solved.out.close();
    }

    InputReader cin = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(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 int nextInt() {
        return Integer.parseInt(next());
    }

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


import java.util.*;

public class Main {

    static Scanner cin = new Scanner(System.in);
    private int xs, ys, n;
    private int[] x, y;

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

    class Item implements Comparable<Item> {

        int w, h, idx;

        Item(int w, int h, int idx) {
            this.w = w;
            this.h = h;
            this.idx = idx;
        }

        @Override
        public int compareTo(Item o) {
            if (this.w == o.w) {
                return this.h - o.h;
            }
            return this.w - o.w;
        }
    }

    private void run() throws Exception {
        xs = cin.nextInt();
        ys = cin.nextInt();
        n = cin.nextInt();
        x = new int[n + 1];
        y = new int[n + 1];
        for (int i = 0; i < n; i++) {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();
        }
        int[] res = new int[1 << n];
        Arrays.fill(res, Integer.MAX_VALUE);
        int[] ds = new int[n];
        for (int i = 0; i < n; i++) {
            ds[i] = (x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys);
        }
        int[][] d = new int[n + 1][n + 1];
        int[] tr = new int[1 << n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            }
        }
        //----------------------
        res[0] = 0;
        for (int i = 1; i < (1 << n); i++) {
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) != 0) {
                    if (res[i - (1 << j)] + 2 * ds[j] < res[i]) {
                        res[i] = res[i - (1 << j)] + 2 * ds[j];
                        tr[i] = i - (1 << j);
                    }
                    for (int k = j + 1; k < n; k++) {
                        if (((i >> k) & 1) != 0) {
                            if (res[i - (1 << j) - (1 << k)] + ds[k] + ds[j] + d[k][j] < res[i]) {
                                res[i] = res[i - (1 << j) - (1 << k)] + ds[k] + ds[j] + d[k][j];
                                tr[i] = i - (1 << j) - (1 << k);
                            }
                        }
                    }
                    break;
                }
            }
        }
        System.out.println(res[(1 << n) - 1]);
        int now = (1 << n) - 1;
        while (now != 0) {
            System.out.print("0 ");
            int dif = now - tr[now];
            for (int i = 0; i < n && dif != 0; i++) {
                if (((dif >> i) & 1) != 0) {
                    System.out.print((i + 1) + " ");
                    dif -= (1 << i);
                }
            }
            now=tr[now];
        }
        System.out.print("0");
    }
}


import java.util.*;

public class cf16e {
	static int n;
	static double[][] prob;
	static double[] memo;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		prob = new double[n][n];
		memo = new double[1<<n];
		for(int i=0; i<n; i++)
			for(int j=0; j<n; j++)
				prob[i][j] = in.nextDouble();
		memo[(1<<n)-1] = 1;
		for(int k=(1<<n)-1; k>0; k--) {
			int numWays = Integer.bitCount(k);
			numWays = (numWays*(numWays-1))/2;
			for(int first = 0; first < n; first++) {
				if(!isSet(k,first)) continue;
				for(int second = first+1; second < n; second++) {
					if(!isSet(k,second)) continue;
					memo[reset(k,first)] += prob[second][first]*memo[k]/numWays;
					memo[reset(k,second)] += prob[first][second]*memo[k]/numWays;
				}
			}
		}
		for(int i=0; i<n; i++)
			System.out.printf("%.6f ", memo[set(0,i)]);
		System.out.println();
	}
	static boolean isSet(int x, int p) {
		return (x&(1<<p)) != 0;
	}
	static int set(int x, int p) {
		return x|(1<<p);
	}
	static int reset(int x, int p) {
		return x&~(1<<p);
	}
	static boolean isDone(int x) {
		return Integer.bitCount(x)==n-1;
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/14/11
 * Time: 9:53 PM
 * To change this template use File | Settings | File Templates.
 */

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

public class Fish extends Thread {

    public Fish() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static int getOnes(int mask) {
        int result = 0;
        while (mask != 0) {
            mask &= mask - 1;
            ++result;
        }
        return result;
    }

    private void solve() throws Throwable {
        int n = nextInt();
        double[][] a = new double[n][n];
        double[] dp = new double[(1 << n)];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        }
        int limit = (1 << n) - 1;
        //dp[mask] = probability of current subset (mask) to remain in the end
        dp[limit] = 1.0;
        for (int mask = limit; mask > 0; --mask) {
            int cardinality = getOnes(mask);
            if (cardinality < 2) {
                continue;
            }
            int probability = cardinality * (cardinality - 1) / 2;
            for (int first = 0; first < n; ++first) {
                if ((mask & powers[first]) != 0) {
                    for (int second = first + 1; second < n; ++second) {
                        if ((mask & powers[second]) != 0) {
                            dp[mask - powers[first]] += dp[mask] * a[second][first] / probability;
                            dp[mask - powers[second]] += dp[mask] * a[first][second] / probability;
                        }

                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            output.printf("%.10f ", dp[powers[i]]);
        }
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

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

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

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

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

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

    static final int powers[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}


import java.util.*;
import java.text.*;
import java.math.*;

public class Main{

    static double EPS=1e-10;
    static double PI=Math.acos(-1.0);

    static double p[][]=new double[25][25];
    static double f[]=new double[1<<20];
    static int n;

    public static void PR(String s){
        System.out.print(s);
    }

    public static void PR(double s)
    {
        java.text.DecimalFormat d=new java.text.DecimalFormat("#.0000000");
        System.out.print(d.format(s));
    }

    public static void DP()
    {
        int i,j,k,cnt;
        for(i=0;i<(1<<n);i++) f[i]=0;
        f[(1<<n)-1]=1;
        for(k=(1<<n)-1;k>=0;k--)
        {
            cnt=0;
            for(i=0;i<n;i++) if((k&(1<<i))!=0) cnt++;
            for(i=0;i<n;i++) if((k&(1<<i))!=0)
            {
                for(j=0;j<n;j++) if(i!=j&&(k&(1<<j))!=0)
                {
                    f[k^(1<<j)]+=f[k]*p[i][j]/((cnt-1)*cnt/2);
                }
            }
        }
    }

    public static void main(String[] args){

        Scanner S=new Scanner(System.in);
        while(S.hasNext())
        {
            n=S.nextInt();
            int i,j;
            for(i=0;i<n;i++) for(j=0;j<n;j++) p[i][j]=S.nextDouble();
            DP();
            for(i=0;i<n;i++)
            {
                if(i!=0) PR(" ");
                PR(f[1<<i]);
            }
            PR("\n");
        }
    }
}


import java.text.DecimalFormat;
import java.util.Scanner;

/**
 *
 * @author Alvaro
 */
public class Main{
    public static int n;
    public static double [] dp;
    public static double [][] p;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        dp = new double[1<<n];
        p = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                p[i][j]= in.nextDouble();
            }
        }
        for (int i = 0; i <(1<<n); i++) {
            dp[i] = -1;
        }
        dp[(1<<n)-1]=1;
        DecimalFormat d = new DecimalFormat("0.000000");
        System.out.print(d.format(f(1<<0)));
        for (int i = 1; i < n; i++) {
            System.out.print(" "+d.format(f(1<<i)));
        }
    }

    public static double f(int mask) {
        if(dp[mask]>-0.5) return dp[mask];
        dp[mask] = 0;
        int vivos = 1;
        for (int i = 0; i < n; i++)
            if((mask>>i)%2==1) vivos++;
        double pares = (vivos*(vivos-1))/2;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if((mask&(1<<i))!=0&&(mask&(1<<j))==0){
                    dp[mask]+=f(mask|(1<<j))*p[i][j]/pares;
                }
            }

        }
        return dp[mask];

    }

}


import java.util.HashMap;
import java.util.Scanner;

import javax.swing.text.html.HTMLDocument.Iterator;

public class Main
{
    public static double p[];
    static double s[];
    static double m[];
    static int n;
    public static double a[][];
    public static int index=0;
    public static boolean vis[];
    public static HashMap<Integer, Integer> permMap;

    public static void main(String g[])
    {

        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        m = new double[(1<<n) +1];
        vis = new boolean[(1<<n) +1];
        a = new double[n][n];

        for(int i=0;i<n;i++)
                {
            for(int j=0;j<n;j++)
            {
                //System.out.println("read"+(c++));
                a[i][j] = sc.nextDouble();
            }
                }

        s = new double[1<<n]; // 2^n
        int perm=0;
        m[0]=1;
        p();

//      System.out.println("answers : ");

        int c=((1<<n)-1);
        for(int i=0;i<n;i++)
        {
            perm = c-(1<<i);
//          System.out.printf("permutation = %x, prob = %f\n",perm,m[perm]);
            System.out.printf("%.6f ",m[perm]);
        }
//      getPerms(0);
//      p(perm);

//      double res[] = new double[n];
//      for(int i=0;i<n;i++)
        {
//          for(int j=0;j<n;j++)
//          if((i&(i-1))!=0)
//              continue;

//          res[i] =
//              p(perm,n);
//          System.out.println(m[i][j]);
        }

//      int cur=(1<<n)-1;
//
//int i=0;
//      for(i=0;i<n;i++)
//      {
//          int val=(cur-(1<<i));
//          int L = n-1;
//          System.out.printf("running for %x .... P = %f\n",val,getProb(val,L));
//
//      }

        //getP((1<<n)-1));

//      for(int i=0;i<m.length;i++)
//      {
//          System.out.println(m[perm]);
//      }

    }

    public static void p()
    {

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

                int perm=k;
        for(int j=0;j<n;j++)
        {

            if(bitTest(perm, j))
            {
                continue;
            }

            int newPerm=perm|(1<<j);    // j got eaten

            for(int i=0;i<n;i++)
            {
                if( (i==j) || bitTest(newPerm,i))
                {
                    continue;
                }
                // i eats j

                int  L=n-countO(perm);
                if(L<2)
                {
                    continue;
                }
                //System.out.println("L="+L);
                double pm = 2.0/(L*(L-1));

//              System.out.printf("Left with %d,%d eats %d \n",L,i,j);
                m[newPerm]+=m[perm]*a[i][j]*pm;
//              System.out.printf("p(%x)= %f \n",newPerm,m[newPerm]);
                //System.out.printf("p(%x)= %f \n",newPerm2,m[newPerm2]);
            }
//          System.out.printf("p(%x)= %f \n",newPerm,m[newPerm]);
//          System.out.println("here-------------------->");

        }

            }

    }

    private static int countO(int marked) {
        // TODO Auto-generated method stub

        int count=0;
        for(int i=0;i<n;i++)
        {
            int test = (1<<i);
            if((test&marked)==(test))
                count++;
        }
        return count;
    }

    private static boolean bitTest(int perm, int i) {
        // TODO Auto-generated method stub
        int test = (1<<i);
        if((test&perm)==test)
            return true;
        return false;
    }

    private static int bitSet(int perm, int i) {
        // TODO Auto-generated method stub
        int np = (1<<i);
        return np;
    }

}


import java.io.*;
public class Main
{
    static double arr[][];
    public static void main(String[] args)
    {
        try
        {
            Parserdoubt pd=new Parserdoubt(System.in);
            PrintWriter pw=new PrintWriter(System.out);
            int fishes=pd.nextInt();
            arr=new double[fishes][fishes];
            for(int i=0;i<fishes;i++)
                for(int j=0;j<fishes;j++)
                    arr[i][j]=Double.parseDouble(pd.nextString());
            double dp[]=new double[(1<<fishes)];
            dp[dp.length-1]=1.0;
            for(int c=dp.length-1;c>=0;c--)
            {

                if((c&(c-1))==0)
                    continue;
                for(int i=0;i<fishes;i++)
                    for(int j=i+1;j<fishes;j++)
                    {
                        if(((1<<i)&c)!=0&&((1<<j)&c)!=0)
                        {
                            dp[c&~(1<<j)]+=arr[i][j]*dp[c];
                            dp[c&~(1<<i)]+=arr[j][i]*dp[c];
                        }
                    }
            }
            double s=0.0;
            for(int i=0;i<fishes;i++)
                s+=dp[1<<i];
            for(int i=0;i<fishes;i++)
                dp[1<<i]/=s;
            int i=0;
            for(i=0;i<fishes-1;i++)
                pw.printf("%.6f ",dp[1<<i]);
            pw.printf("%.6f\n",dp[1<<i]);
            pw.close();
        }
        catch(Exception e)
        {}
    }
}
class Parserdoubt
    {
       final private int BUFFER_SIZE = 1 << 17;

       private DataInputStream din;
       private byte[] buffer;
       private int bufferPointer, bytesRead;

       public Parserdoubt(InputStream in)
       {
          din = new DataInputStream(in);
          buffer = new byte[BUFFER_SIZE];
          bufferPointer = bytesRead = 0;
       }
       public String nextString() throws Exception
       {
           StringBuffer sb=new StringBuffer("");
           byte c = read();
           while (c <= ' ') c = read();
           do
           {
               sb.append((char)c);
               c=read();
           }while(c>' ');
           return sb.toString();
       }
       public char nextChar() throws Exception
       {
           byte c=read();
           while(c<=' ') c= read();
           return (char)c;
       }
       public int nextInt() throws Exception
       {
          int ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       public long nextLong() throws Exception
       {
          long ret = 0;
          byte c = read();
          while (c <= ' ') c = read();
          boolean neg = c == '-';
          if (neg) c = read();
          do
          {
              ret = ret * 10 + c - '0';
             c = read();
          } while (c > ' ');
          if (neg) return -ret;
          return ret;
       }
       private void fillBuffer() throws Exception
       {
          bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
          if (bytesRead == -1) buffer[0] = -1;
       }

       private byte read() throws Exception
       {
          if (bufferPointer == bytesRead) fillBuffer();
          return buffer[bufferPointer++];
       }
    }


/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/14/11
 * Time: 9:53 PM
 * To change this template use File | Settings | File Templates.
 */

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

public class Fish extends Thread {

    public Fish() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static int getOnes(int mask) {
        int result = 0;
        while (mask != 0) {
            mask &= mask - 1;
            ++result;
        }
        return result;
    }

    private void solve() throws Throwable {
        int n = nextInt();
        double[][] a = new double[n][n];
        double[] dp = new double[(1 << n)];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        }
        int limit = (1 << n) - 1;
        //dp[mask] = probability of current subset (mask) to remain in the end
        dp[limit] = 1.0;
        for (int mask = limit; mask > 0; --mask) {
            int cardinality = getOnes(mask);
            int probability = cardinality * (cardinality - 1) / 2;
            for (int first = 0; first < n; ++first) {
                if ((mask & powers[first]) != 0) {
                    for (int second = first + 1; second < n; ++second) {
                        if ((mask & powers[second]) != 0) {
                            dp[mask - powers[first]] += dp[mask] * a[second][first] / probability;
                            dp[mask - powers[second]] += dp[mask] * a[first][second] / probability;
                        }

                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            output.printf("%.10f ", dp[powers[i]]);
        }
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

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

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

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

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

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

    static final int powers[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 11.01.11
 * Time: 4:14
 * To change this template use File | Settings | File Templates.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.Exchanger;

public class Template {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

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

    void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }
    double dm[];
    double a[][];
    boolean fil[];
    int p[];
    int n;
    // x & (x - 1)
    // 10
    //
    void solve() throws  IOException {
        n = nextInt();
        a = new double[n][n];
        for(int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        dm = new double[1 << n];
        dm[(1 << n) - 1] = 1;
        for(int mask = (1 << n) - 1; mask >= 1; --mask) {
            int c = Integer.bitCount(mask);
            if (c == 1) continue ;
            double p = 2.0 / (double)(c - 1) / (double) c;
            for(int i = 0; i < n; ++i) {
                for (int j =0 ; j < n; ++j) {
                    if (i != j && (mask & (1 << i)) > 0 && (mask & (1 << j)) > 0) {
                        dm[mask ^ (1 << j)] += a[i][j] * dm[mask] * p;
                    }
                }
            }
        }
        for(int i = 0; i < n; ++i) {
            out.print(dm[1 << i] + " ");
        }
    }

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

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

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

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


import java.util.*;

public class E
{
   public static void main(String[] args)
   {
      new E(new Scanner(System.in));
   }

   public E(Scanner in)
   {
      int N = in.nextInt();
      double[][] g = new double[N][N];

      for (int j=0; j<N; j++)
         for (int i=0; i<N; i++)
            g[i][j] = in.nextDouble();

      double[] memo = new double[1<<N];
      memo[(1<<N)-1] = 1.0;

      for (int m=(1<<N)-1; m>0; m--)
      {
         int cnt = 0;
         for (int i=0; i<N; i++)
         {
            int m1 = 1 << i;
            if ((m1&m) > 0)
               cnt++;
         }

         int sum = (cnt*(cnt-1))/2;
         for (int i=0; i<N; i++)
         {
            int m1 = 1 << i;
            if ((m1&m) == 0) continue;

            for (int j=i+1; j<N; j++)
            {
               int m2 = 1 << j;
               if ((m2&m) == 0) continue;

               memo[m-m1] += (g[i][j]*memo[m])/sum;
               memo[m-m2] += (g[j][i]*memo[m])/sum;
            }
         }
      }

      StringBuilder sb = new StringBuilder();
      for (int i=0; i<N; i++)
      {
         double res = memo[1<<i];
         sb.append(String.format("%.8f", res));
         sb.append(' ');
      }
      System.out.println(sb.toString().trim());
   }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.*;

/**
 *
 * @author jon
 */
public class Fish {
    double memo[] = new double[(1<<18)];
    int N, FULL;
    double prob[][] = new double[18][18];
    Fish() {
        Scanner in = new Scanner(System.in);
        Arrays.fill(memo, -1);

        N = in.nextInt();
        FULL = (1<<N) - 1;

        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                prob[i][j] = in.nextDouble();
            }
        }

        for(int i = 0; i < N; i++) {
            System.out.printf("%.6f ", go((1<<i)));
        }
        System.out.println();

    }
    public double go(int mask) {
        if(mask == FULL) return 1.0;
        if(memo[mask] >= 0) return memo[mask];
        double ret = 0;
        double mult = Integer.bitCount(mask) + 1;
        mult *= (mult-1)/2.0;

        for(int i = 0; i < N; i++) {
            if(((1<<i) & mask) != 0) {
                for(int j = 0; j < N; j++) {
                    if(((1<<j) & mask) == 0) {
                        ret += go(mask | (1<<j)) * prob[i][j];
                    }
                }
            }
        }
        ret /= mult;

        memo[mask] = ret;
        return ret;
    }
    public static void main(String args[]) {
        new Fish();
    }
}


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

public class A {

	static double[][] a;
	static int N;
	static double[][] memo;

	static double[] dp(int alive)
	{
		int count = Integer.bitCount(alive);
		if(count == 1)
		{
			double[] ret = new double[N];
			for(int i = 0; i < N; ++i)
				if((alive & (1<<i)) != 0)
				{
					ret[i] = 1;
					break;
				}
			return memo[alive] = ret;
		}
		if(memo[alive] != null)
			return memo[alive];

		double[] ret = new double[N];
		for(int j = 0; j < N; ++j)
			if((alive & (1<<j)) != 0)
			{
				double[] nxt = dp(alive & ~(1<<j));
				for(int i = 0; i < N; ++i)
					ret[i] += die[j][alive] * nxt[i];
			}
		return memo[alive] = ret;
	}

	static double[][] die;
	static void f()
	{
		die = new double[N][1<<N];
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < 1<<N; ++j)
			{
				int count = Integer.bitCount(j);
				if(count <= 1)
					continue;
				double prop = 1.0 / (count * (count - 1) >> 1);
				for(int k = 0; k < N; ++k)
					if((j & (1<<k)) != 0)
						die[i][j] += prop * a[k][i];
			}

	}

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

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		N = sc.nextInt();

		a = new double[N][N];
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j)
				a[i][j] = sc.nextDouble();
		memo = new double[1<<N][];

		f();

		double[] ret = dp((1<<N) - 1);
		for(int i = 0; i < N - 1; ++i)
			out.printf("%.8f ",ret[i]);
		out.printf("%.8f\n", ret[N-1]);

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

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

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

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

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

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

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

		public boolean ready() throws IOException {return br.ready();}

	}
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {

    private int n;
    private double[] dp;
    private double[][] p;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        p = new double[n][n];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                p[i][j] = in.nextDouble();
            }
        }
        dp = new double[1 << n];
        Arrays.fill(dp, -1);
        for (int i = 0; i < n; ++i) {
            out.printf("%.6f ", rec(1 << i));
        }
        out.println();
    }

    private double rec(int mask) {
        if (mask == (1 << n) - 1) return 1;
        if (dp[mask] > -0.5) return dp[mask];
        double res = 0;
        int nn = Integer.bitCount(mask);
        int total = (nn * (nn + 1)) / 2;
        for (int i = 0; i < n; ++i) if (BitUtils.checkBit(mask, i)) for (int j = 0; j < n; ++j) if (!BitUtils.checkBit(mask, j)) {
            res += rec(BitUtils.setBit(mask, j)) * p[i][j];
        }
        res /= total;
        dp[mask] = res;
        return res;
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine().trim();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

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

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

}

class BitUtils {
    public static boolean checkBit(int mask, int bit) {
        return (mask & (1 << bit)) > 0;
    }

    public static int setBit(int mask, int bit) {
        return (mask | (1 << bit));
    }

}


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

public class e{
  int n;
  double f[];
  double a[][];

  public void run(){
    Locale.setDefault(Locale.US);
    Scanner in = new Scanner(System.in);
    n = in.nextInt();
    a = new double[n][n];
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j] = in.nextDouble();
    f = new double[1<<n];
    for(int i=0;i<1<<n;i++) f[i] = -1;
    f[(1<<n)-1] = 1.0;

    for(int i=0;i<n;i++) System.out.print(doIt(1<<i) + " ");
  }

  private double doIt(int mask){
    if (f[mask] >=0) return f[mask];
    f[mask] = 0;
    double k = getBits(mask);
    k*=(k-1)/2.0;

    for(int i=0;i<n;i++)
      if ((mask & (1 << i)) > 0)
        for(int j=0;j<n;j++)
          if ((mask & (1 << j)) == 0)
            f[mask]+=doIt(mask|(1<<j))*a[i][j]/k;
    return f[mask];
  }
  private int getBits(int x){
    int cnt = 0;
    while(x > 0){
      x&=(x-1);
      cnt++;
    }
    return cnt+1;
  }

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


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

public class Fish
{
	static double[][] prob= new double[18][18];
	static double[][] dp= new double[2][1<<18];
	static ArrayList<Integer>[] adj= new ArrayList[1<<18];
	static int n;
	public static void init()
	{
		for(int i=0; i<(1<<18); i++)
			adj[i]= new ArrayList<Integer>();
		for(int i=0; i<(1<<18); i++)
			for(int j=0; j<18; j++)
				if(((i>>j)&1)==1)
					adj[i].add(i^(1<<j));
	}
	public static double value(int cur, int next)
	{
		int i=0;
		int z= cur^next;
		double p=0;
		int alive= Integer.bitCount(cur);
		while((z>>i)!=1)
			i++;
		for(int k=0; k<n; k++)
			if( ((next>>k)&1)==1)
				p+= prob[k][i];
		p/= alive*(alive-1)/2;
		return p;
	}
	public static void main(String[] args)throws Exception
	{
		Scanner scan= new Scanner(System.in);
		init();
		n=scan.nextInt();
		int m= (1<<n)-1;
		for(int i=0; i<n; i++)
			for(int j=0; j<n; j++)
				prob[i][j]= scan.nextDouble();
		dp[0][m]=1;

		for(int i=0; i<(n-1); i++)
		{
			for(int j=0; j<=m; j++)
				if(dp[i%2][j]>0)
					for(Integer next: adj[j])
						dp[(i+1)%2][next]+= value(j,next)*dp[i%2][j];
			Arrays.fill(dp[i%2],0);
		}

		for(int i=0; i<n; i++)
		{
			if(i!=0)
			System.out.print(" ");
			System.out.printf("%.6f",dp[(n-1)%2][1<<i]);
		}

	}
}


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

public class e {
	private void main() {
		Scanner stdin = new Scanner(System.in);
		PrintStream stdout = System.out;
		int n = stdin.nextInt();
		double[][] p = new double[n][n];
		double[][] ans = new double[1<<n][n];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				p[i][j] = stdin.nextDouble();
		double[] dieChance = new double[n];
		ArrayList<Integer> sel = new ArrayList<Integer>();
		for(int i = 0; i < (1<<n); i++) {
			sel.clear();
			for(int k = 0; k < n; k++) {
				if((i & (1<<k)) != 0)
					sel.add(k);
			}
			if(sel.size() == 1) {
				ans[i][sel.get(0)] = 0;
				continue;
			}
			for(int j : sel)
				dieChance[j] = 0;
			for(int j : sel)
				for(int k : sel)
					dieChance[k] += p[j][k];
			for(int j : sel)
				dieChance[j] /= sel.size()*(sel.size()-1)/2;
			for(int j : sel) {
				ans[i][j] = dieChance[j];
				for(int k : sel)
					ans[i][j] += dieChance[k] * ans[i-(1<<k)][j];
			}
		}
		for(double d : ans[(1<<n)-1])
			stdout.format("%f ", 1-d);
		stdout.println();
	}
	public static void main(String[] args) {
		new e().main();
	}
}


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

public class P16E {
    int n;
    double [][]prob;
    double []dp;
    public P16E() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        prob = new double [n][n];
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                prob[i][j] = sc.nextDouble();
            }
        }
        sc.close();

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

        for (int i = 0; i < n; i++) {
            int a = 1 << i;
            System.out.print(compute(a) + " ");
        }
    }

    double compute (int mask){
        if (mask == (1<<n) - 1){
            return 1;
        }
        if (dp[mask] != -1){
            return dp[mask];
        }
        double result = 0;
        int c = 0;
        for (int i = 0; i < n; i++) {
            int a = 1 << i;
            if ((a & mask) != 0) {
                c++;
                for (int j = 0; j < n; j++) {
                    int b = 1 << j;
                    if ((b & mask) == 0) {
                        result += (prob[i][j] * compute(mask | b));
                    }
                }
            }
        }

        int nC2 = (c + 1) * c / 2;
        dp[mask] = result / nC2;
        return dp[mask];

    }

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


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

public class Main {

    public static void main(String[] args) throws Exception {
        //System.setIn(new FileInputStream("1"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = nextInt();
        double[][] a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = nextDouble();
            }
        }
        double[] dp = new double[1 << n];
        dp[(1 << n) - 1] = 1.0;
        for (int mask = (1 << n) - 2; mask > 0; mask--) {
            int count = Integer.bitCount(mask);
            double pPair = 2.0 / (count * (count + 1));
            double ans = 0.0;
            for (int i = 0; i < n; i++) {
                if (((1 << i) & mask) == 0) {
                    double p = dp[(1 << i) | mask];
                    double s = 0.0;
                    for (int j = 0; j < n; j++) {
                        if (((1 << j) & mask) != 0)
                            s += a[j][i];
                    }
                    ans += pPair * p * s;
                }
            }
            dp[mask] = ans;
        }

        for (int i = 0; i < n; i++) {
            out.print(dp[1 << i]);
            out.print(' ');
        }

        in.close();
        out.close();
    }

    static StringTokenizer st;
    static BufferedReader in;
    static PrintWriter out;

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

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

    static String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}


import java.util.*;
public class Main {
public static void main(String [] args){
	Scanner in=new Scanner(System.in);
	int n=in.nextInt();
	double value[][]=new double[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)value[i][j]=in.nextDouble();
		double ans[]=new double[1<<n];
		int mask=(1<<n);
		ans[(1<<n)-1]=1.0;
		for(int i=mask-1;i>=0;i--){
		int cnt=Integer.bitCount(i);
		int pairs=cnt*(cnt-1)/2;
		for(int j=0;j<n;j++){
		if(((i>>j)&1)==0)continue;
		for(int k=j+1;k<n;k++){
		if(((i>>k)&1)==0)continue;
		ans[i^(1<<k)]+=ans[i]*value[j][k]/pairs;
		ans[i^(1<<j)]+=ans[i]*value[k][j]/pairs;
		}
		}
		}
		for(int i=0;i<n;i++)
			System.out.print(ans[1<<i]+" ");

}
}