codeparrot/codecomplex huggingface dataset:
// Problem: 112_E. Petya and Spiders
// Time complexity: np
/*(c) gorlum0 [at] gmail.com*/
import java.io.*;
import java.util.*;
import java.math.*;

public class E
{
    int bitcount(int x) {
        int c = 0;
        for ( ; x != 0; c++)
            x &= x-1;
        return c;
    }

    boolean bit(int x, int i)
    {
        if (i < 0) return false;
        return (x>>i & 1) == 1 ? true : false;
    }

    int solve(int n, int m)
    {
        if (m > n) { int x = m; m = n; n = x; }
        int maxmask = 1<<m;

        int[][][] dp = new int[n+1][maxmask][maxmask];
        for (int i = 0; i <= n; i++)
            for (int j = 0; j < maxmask; j++)
                for (int k = 0; k < maxmask; k++)
                    dp[i][j][k] = inf;
        for (int i = 0; i < maxmask; i++)
            dp[0][0][i] = bitcount(i);

        for (int i = 1; i <= n; i++)
            for (int b = 0; b < maxmask; b++)
                for (int c = 0; c < maxmask; c++)
                    for (int a = 0; a < maxmask; a++) {
                        boolean nospider = false;
                        for (int j = 0; j < m; j++)
                            if (not(bit(a,j) || bit(c,j) || bit(b,j-1) || bit(b,j) || bit(b,j+1))) {
                                nospider = true;
                                break;
                            }
                        if (nospider) continue;

                        dp[i][b][c] = Math.min(dp[i][b][c], dp[i-1][a][b] + bitcount(c));
                    }
        int res = inf;
        for (int b = 0; b < maxmask; b++)
            res = Math.min(res, dp[n][b][0]);
        return n*m - res;
    }

    void main() throws IOException {
        int n;
        while ((n = nextInt()) != EOF) {
            int m = nextInt();
            out.println(solve(n, m));
        }
    }

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

    // ======================================================================

    int inf = (int) 1e9;
    final int EOF = -1;

    boolean not(boolean p) { return !p; }

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

    BufferedReader fin;
    StringTokenizer st;
    PrintWriter out;

    public void run() {
        try {
            fin = new BufferedReader(new InputStreamReader(System.in));
            st = null;
            out = new PrintWriter(System.out);
            main();
            fin.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = fin.readLine();
            if (line == null) return "-1";
            else st = new StringTokenizer(line);
        }
        return st.nextToken();
    }
}
// Problem: 112_E. Petya and Spiders
// Time complexity: np

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

public class E {
    static int n;
    static int m;
    static int[][][] DP;
    static int[] dx = { 0, 0, 1, -1 };
    static int[] dy = { 1, -1, 0, 0 };
    static int inf = 1000000;

    public static int get(int x, int current, int last) {
        if (x == n) {
            if (last == 0)
                return 0;
            else
                return -inf;
        }
        if (DP[x][current][last] != -1)
            return DP[x][current][last];
        int max = 0;
        for (int mask = 0; mask < (1 << m); mask++) {
            int tempLast = last;
            int tempCurrent = current;
            int tempNext = (1 << m) - 1;
            for (int i = 0; i < m; i++)
                if ((mask & (1 << i)) != 0) {
                    if (i > 0)
                        tempCurrent &= ~(1 << (i - 1));
                    if (i < m - 1)
                        tempCurrent &= ~(1 << (i + 1));
                    tempNext &= ~(1 << (i));
                    tempLast &= ~(1 << (i));
                }
            if (tempLast != 0)
                continue;
            max = Math.max(
                    max,
                    m - Integer.bitCount(mask)
                            + get(x + 1, tempNext, tempCurrent & ~mask));
        }
        return DP[x][current][last] = max;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        n = Math.max(x, y);
        m = Math.min(x, y);
        DP = new int[n][1 << m][1 << m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < (1 << m); j++)
                Arrays.fill(DP[i][j], -1);
        System.out.println(get(0, (1 << m) - 1, 0));
    }
}
// Problem: 1209_E2. Rotate Columns (hard version)
// Time complexity: np
import java.util.*;
import java.io.*;

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

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		int t=in.nextInt();
		for(int i=0;i<t;i++) {
			out.println(work());
		}
		out.flush();
	}
	long mod=1000000007;
	long gcd(long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
	int work() {
		int n=in.nextInt();
		int m=in.nextInt();
		int[][] A=new int[n][m];
		int[][] B=new int[n][m];
		int[][] R=new int[m][2];
		for(int i=0;i<m;i++)R[i][1]=i;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j]=in.nextInt();
				R[j][0]=Math.max(R[j][0], A[i][j]);
			}
		}
		Arrays.sort(R,new Comparator<int[]>() {
			public int compare(int[] arr1,int[] arr2) {
				return arr2[0]-arr1[0];
			}
		});
		for(int j=0;j<m;j++) {
			int index=R[j][1];
			for(int i=0;i<n;i++) {
				B[i][j]=A[i][index];
			}
		}
		m=Math.min(n, m);
		int[][] dp=new int[m][1<<n];
		int[][] rec=new int[m][1<<n];
		for(int j=0;j<m;j++) {
			for(int s=0;s<n;s++) {//转
				for(int i=1;i<1<<n;i++) {
					int sum=0;
					for(int b=0;b<n;b++) {
						if(((1<<b)&i)>0) {
							sum+=B[(b+s)%n][j];
						}
					}
					rec[j][i]=Math.max(sum, rec[j][i]);
				}
			}
		}
		
		for(int j=0;j<m;j++) {
			for(int i=0;i<1<<n;i++) {
				if(j==0) {
					dp[j][i]=rec[j][i];
				}else {
					for(int p=i;p<1<<n;p++) {
						p=p|i;
						dp[j][p]=Math.max(dp[j][p], rec[j][i]+dp[j-1][p^i]);
					}
				}
			}
		}
		return dp[m-1][(1<<n)-1];
	}
}



class FastReader
{
	BufferedReader br;
	StringTokenizer st;

	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}

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

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

	public long nextLong()
	{
		return Long.parseLong(next());
	}
}
// Problem: 1209_E2. Rotate Columns (hard version)
// Time complexity: np
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;
import static java.util.Arrays.fill;

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

public class E {

	static void solve() throws Exception {
		int tests = scanInt();
//		int tests = 40;
		for (int test = 0; test < tests; test++) {
			int n = scanInt(), m = scanInt(), a[][] = new int[n][m];
//			int n = 12, m = 2000, a[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					a[i][j] = scanInt();
				}
			}
			int bestCols[] = new int[min(m, n)];
			for (int i = 0; i < bestCols.length; i++) {
				bestCols[i] = i;
			}
			if (m > n) {
				int bestColMax[] = new int[n];
				for (int i = 0; i < n; i++) {
					int cmax = 0;
					for (int j = 0; j < n; j++) {
						cmax = max(cmax, a[j][i]);
					}
					bestColMax[i] = cmax;
				}
				for (int i = n; i < m; i++) {
					int cmax = 0;
					for (int j = 0; j < n; j++) {
						cmax = max(cmax, a[j][i]);
					}
					int minBC = 0, minBCM = Integer.MAX_VALUE;
					for (int j = 0; j < n; j++) {
						if (bestColMax[j] < minBCM) {
							minBC = j;
							minBCM = bestColMax[j];
						}
					}
					if (cmax > minBCM) {
						bestCols[minBC] = i;
						bestColMax[minBC] = cmax;
					}
				}
			}
			int dyn[] = new int[1 << n], dynNext[] = new int[1 << n], sums[] = new int[1 << n], csums[] = new int[1 << n];
			for (int i: bestCols) {
				fill(dynNext, 0);
				fill(sums, 0);
				for (int j = 0; j < n; j++) {
					for (int k = 1, bit = 0; k < 1 << n; k++) {
						if (k == 1 << (bit + 1)) {
							++bit;
						}
						sums[k] = max(sums[k], csums[k] = csums[k ^ (1 << bit)] + a[(bit + j) % n][i]);
					}
				}
				for (int mask1 = 0; mask1 < 1 << n; mask1++) {
					int cdyn = dynNext[mask1];
					for (int mask2 = mask1;; mask2 = (mask2 - 1) & mask1) {
						cdyn = max(cdyn, dyn[mask2] + sums[mask1 ^ mask2]);
						if (mask2 == 0) {
							break;
						}
					}
					dynNext[mask1] = cdyn;
				}
				int t[] = dyn;
				dyn = dynNext;
				dynNext = t;
			}
			out.println(dyn[(1 << n) - 1]);
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

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

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}
// Problem: 1209_E2. Rotate Columns (hard version)
// Time complexity: np
import java.util.*;
import java.io.*;

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

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		int t=in.nextInt();
		for(int i=0;i<t;i++) {
			out.println(work());
		}
		out.flush();
	}
	long mod=1000000007;
	long gcd(long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
	int work() {
		int n=in.nextInt();
		int m=in.nextInt();
		int[][] A=new int[n][m];
		int[][] B=new int[n][m];
		int[][] R=new int[m][2];
		for(int i=0;i<m;i++)R[i][1]=i;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j]=in.nextInt();
				R[j][0]=Math.max(R[j][0], A[i][j]);
			}
		}
		Arrays.sort(R,new Comparator<int[]>() {
			public int compare(int[] arr1,int[] arr2) {
				return arr2[0]-arr1[0];
			}
		});
		for(int j=0;j<m;j++) {
			int index=R[j][1];
			for(int i=0;i<n;i++) {
				B[i][j]=A[i][index];
			}
		}
		m=Math.min(n, m);
		int[][] dp=new int[m][1<<n];
		int[][] rec=new int[m][1<<n];
		for(int j=0;j<m;j++) {
			for(int s=0;s<n;s++) {//转
				for(int i=1;i<1<<n;i++) {
					int sum=0;
					for(int b=0;b<n;b++) {
						if(((1<<b)&i)>0) {
							sum+=B[(b+s)%n][j];
						}
					}
					rec[j][i]=Math.max(sum, rec[j][i]);
				}
			}
		}
		
		for(int j=0;j<m;j++) {
			for(int i=0;i<1<<n;i++) {
				if(j==0) {
					dp[j][i]=rec[j][i];
				}else {
					for(int p=i+1;;p++) {
						if(p>=1<<n)break;
						p=p|i;
						dp[j][p]=Math.max(dp[j][p], rec[j][i]+dp[j-1][p^i]);
					}
				}
			}
		}
		return dp[m-1][(1<<n)-1];
	}
}



class FastReader
{
	BufferedReader br;
	StringTokenizer st;

	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}

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

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

	public long nextLong()
	{
		return Long.parseLong(next());
	}
}
// Problem: 1238_E. Keyboard Purchase
// Time complexity: np
import java.io.*;
import java.util.*;
public class Sol2{
	final public static int MXN = (1<<21);
	public static int good[][];
	public static void main(String[] args) throws IOException{
		FastIO sc = new FastIO(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int num[][] = new int[m][m];
		String str = sc.next();
		for(int i=0; i<str.length()-1; i++) {
			int a = str.charAt(i)-'a';
			int b = str.charAt(i+1)-'a';
			num[a][b]++;
			num[b][a]++;
		}
		int lowbit[] = new int[MXN];
		int dp[] = new int[MXN];
		for(int i=0; i<MXN; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		dp[0] = 0;
		good = new int[MXN][m];
		for(int msk = 0; msk<(1<<m); msk++) {
			for(int i=0; i<m; i++) {
				int low = Integer.numberOfTrailingZeros(Integer.lowestOneBit(msk));
				if(low==32) low = 0;
				good[msk][i] = good[msk^(1<<low)][i] + num[i][low];
			}
		}
		for(int msk = 0; msk<(1<<m); msk++) {
			int bits = Integer.bitCount(msk)+1;
			for(int i=0; i<m; i++) {
				if((msk&(1<<i))!=0) continue;
				int nxt = msk|(1<<i);
				dp[nxt] = Math.min(dp[nxt], dp[msk] + bits*(good[msk][i]-good[((1<<m)-1)^nxt][i]));
			}
		}
		out.println(dp[(1<<m)-1]);
		out.close();
	}
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	static class FastIO {
		 
		// Is your Fast I/O being bad?
 
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
 
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
 
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
 
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
 
		String next() throws IOException {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
 
	}
}
// Problem: 1238_E. Keyboard Purchase
// Time complexity: np
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1238E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         int[][] cnt = new int[M][M];
         for(int i=0; i < N-1; i++)
         if(input.charAt(i) != input.charAt(i+1))
            {
               cnt[input.charAt(i)-'a'][input.charAt(i+1)-'a']++;
               cnt[input.charAt(i+1)-'a'][input.charAt(i)-'a']++;
            }
         int[] dp = new int[1 << M];
         Arrays.fill(dp, Integer.MAX_VALUE);
         dp[0] = 0;
         for(int mask=0; mask < dp.length; mask++)
            for(int b=0; b < M; b++)
               if((mask&(1<<b)) == 0)
               {
                  int submask = mask|(1<<b);
                  int cost = 0;
                  for(int c=0; c < M; c++)
                  {
                     if((mask&(1<<c)) > 0)
                        cost += cnt[b][c];
                     else
                        cost -= cnt[b][c];
                  }
                  dp[submask] = Math.min(dp[submask], dp[mask]+cost*Integer.bitCount(mask));
               }
         System.out.println(dp[(1<<M)-1]);
      }
   }
// Problem: 1238_E. Keyboard Purchase
// Time complexity: np
import java.util.*;
import java.io.*;
 
public class Main {
	public static void main(String args[]) {new Main().run();}
 
	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		out.println(work());
		out.flush();
	}
	long mod=1000000007;
	long gcd(long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
	long work() {
		int n=in.nextInt();
		int m=in.nextInt();
		String str=in.next();
		long[] dp=new long[1<<m];
		long[][] cnt=new long[m][m];
		long[] rec=new long[1<<m];	
   	        for(int i=1;i<n;i++) {
			int n1=str.charAt(i-1)-'a';
			int n2=str.charAt(i)-'a';
			cnt[n1][n2]++;
			cnt[n2][n1]++;
		}
		for(int i=1;i<1<<m;i++) {
			dp[i]=9999999999L;
			long v=0;
			int b=0;//最低位的1
			for(int j=0;j<m;j++) {
				if((i&(1<<j))>0) {
					b=j;
					break;
				}
			}
			for(int j=0;j<m;j++) {
				if((i&(1<<j))==0) {
					v+=cnt[b][j];
				}else {
					if(b!=j)v-=cnt[b][j];
				}
			}
			v+=rec[i-(1<<b)];
			for(int j=0;j<m;j++) {
				if((i&(1<<j))>0) {
					dp[i]=Math.min(dp[i], dp[i-(1<<j)]+v);
				}
			}
			rec[i]=v;
		}
		
		return dp[(1<<m)-1];
	}
}
 
 
 
class FastReader
{
	BufferedReader br;
	StringTokenizer st;
 
	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
 
	public String next() 
	{
		if(st==null || !st.hasMoreElements())
		{
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}
 
	public int nextInt() 
	{
		return Integer.parseInt(next());
	}
 
	public long nextLong()
	{
		return Long.parseLong(next());
	}
}
// Problem: 1238_E. Keyboard Purchase
// Time complexity: np
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.cos;
import static java.lang.Math.min;

public class E_fast {
    static int g[][];
    static int n, m;
    static char[] s;
    static int dp[], inf = (int) 2e9;
    static int cost[][];

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextInt();
        m = in.nextInt();
        s = in.next().toCharArray();
        g = new int[m][m];
        for (int i = 1; i < n; i++) {
            int x = s[i - 1] - 'a', y = s[i] - 'a';
            if (x != y) {
                g[x][y]++;
                g[y][x]++;
            }
        }
        cost = new int[m][1 << m];
        for (int i = 0; i < m; i++) {
            int w = 0;
            for (int j = 0; j < m; j++) w += g[i][j];
            pre(i, 0, 0, -w);
        }
        dp = new int[1 << m];
        Arrays.fill(dp, -1);
        pw.println(solve(0, 0));

        pw.close();
    }

    static void pre(int x, int pos, int mask, int w) {
        if (pos >= m) {
            cost[x][mask] = w;
            return;
        }
        pre(x, pos + 1, mask, w);
        pre(x, pos + 1, set(mask, pos), w + 2 * g[x][pos]);
    }

    static int solve(int pos, int mask) {
        if (pos >= m) return 0;
        if (dp[mask] != -1) return dp[mask];
        int min = inf;
        for (int i = 0; i < m; i++) {
            if (!check(mask, i)) {
                int res = cost[i][mask] * pos + solve(pos + 1, set(mask, i));
                min = min(min, res);
            }
        }
        return dp[mask] = min;
    }

    static boolean check(int N, int pos) {
        return (N & (1 << pos)) != 0;
    }

    static int set(int N, int pos) {
        return N = N | (1 << pos);
    }

    static int reset(int N, int pos) {
        return N = N & ~(1 << pos);
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}
// Problem: 1238_E. Keyboard Purchase
// Time complexity: np
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class KeyboardPurchase {
    static final int INF = 1000000000;
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out, false);
        int N = in.nextInt(), M = in.nextInt();
        String str = in.next();
        int[][] count = new int[M][M];
        for (int i = 1; i < N; i++) {
            char c1 = str.charAt(i - 1), c2 = str.charAt(i);
            count[c1 - 'a'][c2 - 'a']++;
            count[c2 - 'a'][c1 - 'a']++;
        }
        int[] dp = new int[(1 << M)];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int mask = 1; mask < (1 << M); mask++) {
            int slow = 0;
            for (int i = 0; i < M; i++) {
                if ((mask & (1 << i)) != 0) {
                    for (int j = 0; j < M; j++) {
                        if ((mask & (1 << j)) == 0) {
                            slow += count[i][j];
                        }
                    }
                }
            }
            for (int i = 0; i < M; i++) {
                if ((mask & (1 << i)) != 0) {
                    dp[mask] = Math.min(dp[mask], slow + dp[mask ^ (1 << i)]);
                }
            }
        }
        out.println(dp[(1 << M) - 1]);
        out.close();
        System.exit(0);
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}