Problem: Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!

The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.

Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!

How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:

  * for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible. 
  * if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F. 



After the values of the error function have been calculated for all the potential addresses the most suitable one is found. 

To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.

Output

On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

2 10
codeforces
codeforces
codehorses


Output

0
12


Input

9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese


Output

18
14
36
47
14
29
30
0
84

Solution (in JAVA):

Solution:
import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

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

	int max(int a, int b) {
		return a > b ? a : b;
	}
	int min(int a, int b) {
		return a > b ? b : a;
	}

	class RMaxQ {
		int m[];
		int pow;

		RMaxQ(String s) {
			int l = s.length();
			pow = 0;
			while ((1 << pow) < l)
				pow++;
			pow++;
			m = new int[(1 << pow) + 1];
		}
		void increase(int pos) { //start 1
			if (pos <= 0)
				out.println("troll");
			int p = (1 << (pow - 1)) + pos - 1;
			m[p] = pos;
			while (p != 0) {
				if ((2 * p) <= 1 << pow)
					m[p] = max(m[p], m[2 * p]);
				if ((2 * p + 1) <= 1 << pow)
					m[p] = max(m[p], m[2 * p + 1]);
				p >>= 1;
			}
			return;
		}
		int getmax(int l, int r) {
			l = (1 << (pow - 1)) + l - 1;
			r = (1 << (pow - 1)) + r - 1;
			int rez = 0;
			while ((l != 0 || r != 0) && l < r) {
				rez = max(rez, m[l]);
				rez = max(rez, m[r]);
				if (l != 0 && (l & 1) == 1) {
					rez = max(rez, m[l]);
					l++;
				}
				l >>= 1;
				if (r != 0 && (r & 1) == 0) {
					rez = max(rez, m[r]);
					r--;
				}
				r >>= 1;
			}
			if (l == r)
				rez = max(rez, m[r]);
			return rez;
		}
	}

	class RMinQ {
		int m[];
		int pow;

		RMinQ(String s) {
			int l = s.length();
			pow = 0;
			while ((1 << pow) < l)
				pow++;
			pow++;
			m = new int[(1 << pow) + 1];
			Arrays.fill(m, -(1 << 30));
		}
		void increase(int pos) { //start 1
			if (pos <= 0)
				out.println("troll");
			int p = (1 << (pow - 1)) + pos - 1;
			m[p] = -pos;
			while (p != 0) {
				if ((2 * p) <= 1 << pow)
					m[p] = max(m[p], m[2 * p]);
				if ((2 * p + 1) <= 1 << pow)
					m[p] = max(m[p], m[2 * p + 1]);
				p >>= 1;
			}
			return;
		}
		int getmax(int l, int r) {
			l = (1 << (pow - 1)) + l - 1;
			r = (1 << (pow - 1)) + r - 1;
			int rez = -(1 << 30);
			while ((l != 0 || r != 0) && l < r) {
				rez = max(rez, m[l]);
				rez = max(rez, m[r]);
				if (l != 0 && (l & 1) == 1) {
					rez = max(rez, m[l]);
					l++;
				}
				l >>= 1;
				if (r != 0 && (r & 1) == 0) {
					rez = max(rez, m[r]);
					r--;
				}
				r >>= 1;
			}
			if (l == r)
				rez = max(rez, m[r]);
			return rez;
		}
	}

	int fabs(int a) {
		return a < 0 ? -a : a;
	}

	int n = 0;
	int k = 0;

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

		n = nextInt(); 
		k = nextInt();
		String P = nextLine();

		RMaxQ RMQ[] = new RMaxQ[26];
		for (int i = 0; i < 26; i++)
			RMQ[i] = new RMaxQ(P);
		RMinQ RmQ[] = new RMinQ[26];
		for (int i = 0; i < 26; i++)
			RmQ[i] = new RMinQ(P);
		for (int i = 0; i < k; i++) {
			RMQ[P.charAt(i) - 'a'].increase(i + 1);
			RmQ[P.charAt(i) - 'a'].increase(i + 1);
		}
		int ML = P.length();
		while (n-- != 0) {
			String T = nextLine();
			int len = T.length();
			long rez = 0;
			for (int i = 0; i < len; i++) {
				int delta = len+ML; 
//				out.println(T.charAt(i) + "   " + ('z'-'a'));
//				out.println(Arrays.toString(RMQ[T.charAt(i)-'a'].m));
//				out.println(Arrays.toString(RmQ[T.charAt(i)-'a'].m));
//				out.println(delta + "   " + i);
				int Max = RMQ[T.charAt(i) - 'a'].getmax(1, min(i + 1,ML));
				if (Max != 0)
					delta = min(delta, fabs(Max - (i + 1)));
//				out.println("MAX " + Max);
//				out.println(delta);
				int Min = -RmQ[T.charAt(i) - 'a'].getmax(min(i + 1,ML), ML);
				if (Min != (1 << 30))
					delta = min(delta, fabs(Min - (i + 1)));
//				out.println("MIN = " + Min);
//				out.println(delta);
				if(delta != ML + len) rez += delta;
				else rez += len;

			}
			out.println(rez);
		}
//		out.println(Arrays.toString(RMQ['s'-'a'].m));
//
//		out.println(Arrays.toString(RmQ['s'-'a'].m));
//		
//		out.println(Arrays.toString(RmQ['e'-'a'].m));
//		out.println(RmQ['e'-'a'].getmax(8,9));
//		out.println(RmQ['s'-'a'].getmax(8,11));

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

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	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 nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}