#include <bits/stdc++.h>   using namespace std;   const int maxl = 1000 * 100 + 5;   int n, k;   string s;   int dis[30][maxl];   int main() {     cin >> n >> k >> s;     memset(dis, -1, sizeof dis);     for (int i = 0; i < 27; i++) {       queue<int> q;       for (int j = 0; j < k; j++)         if (s[j] == (char)(i +  a )) {           q.push(j);           dis[i][j] = 0;         }       while (!q.empty()) {         int index = q.front();         q.pop();         if (index != 0)           if (dis[i][index - 1] == -1) {             dis[i][index - 1] = dis[i][index] + 1;             q.push(index - 1);           }         if (index != maxl - 1)           if (dis[i][index + 1] == -1) {             dis[i][index + 1] = dis[i][index] + 1;             q.push(index + 1);           }       }     }     for (int j = 0; j < n; j++) {       string tmp;       cin >> tmp;       long long int ans = 0;       for (int i = 0; i < tmp.size(); i++)         ans += (dis[tmp[i] -  a ][i] == -1 ? tmp.size() : dis[tmp[i] -  a ][i]);       cout << ans << endl;     }   }   