The Little Elephant loves strings very much. 

He has an array a from n strings, consisting of lowercase English letters. Let's number the elements of the array from 1 to n, then let's denote the element number i as ai. For each string ai (1 ≤ i ≤ n) the Little Elephant wants to find the number of pairs of integers l and r (1 ≤ l ≤ r ≤ |ai|) such that substring ai[l... r] is a substring to at least k strings from array a (including the i-th string).

Help the Little Elephant solve this problem.

If you are not familiar with the basic notation in string problems, you can find the corresponding definitions in the notes.

Input

The first line contains two space-separated integers — n and k (1 ≤ n, k ≤ 105). Next n lines contain array a. The i-th line contains a non-empty string ai, consisting of lowercase English letter. The total length of all strings ai does not exceed 105.

Output

On a single line print n space-separated integers — the i-th number is the answer for string ai.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3 1
abc
a
ab


Output

6 1 3 


Input

7 4
rubik
furik
abab
baba
aaabbbababa
abababababa
zero


Output

1 0 9 9 21 30 0 

Note

Let's assume that you are given string a = a1a2... a|a|, then let's denote the string's length as |a| and the string's i-th character as ai.

A substring a[l... r] (1 ≤ l ≤ r ≤ |a|) of string a is string alal + 1... ar.

String a is a substring of string b, if there exists such pair of integers l and r (1 ≤ l ≤ r ≤ |b|), that b[l... r] = a.
#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 100005 << 1;
int Log[N];
void init() {
  Log[0] = -1;
  for (int i = 1; i < N; i++) Log[i] = Log[i >> 1] + 1;
}
int arr[N];
char ss[N];
int m, K, pos[N], leng[N], pre[N];
int last[N], sor[N], val[N * 30], start[N << 2], tot, sum;
void setup(int rt, int L, int R) {
  int len = R - L + 1;
  start[rt] = tot;
  for (int i = (int)(L); i <= (int)(R); i++) val[tot++] = pre[i];
  sort(val + start[rt], val + start[rt] + len);
  if (L == R) return;
  int mid = L + R >> 1;
  setup(rt << 1, L, mid);
  setup(rt << 1 | 1, mid + 1, R);
}
int query(int rt, int L, int R, int l, int r, int v) {
  if (l <= L && R <= r) {
    int len = R - L + 1;
    int res = lower_bound(val + start[rt], val + start[rt] + len, v) -
              (val + start[rt]);
    return res;
  }
  int mid = L + R >> 1;
  int res = 0;
  if (l <= mid) res += query(rt << 1, L, mid, l, r, v);
  if (r > mid) res += query(rt << 1 | 1, mid + 1, R, l, r, v);
  return res;
}
struct SA {
  int s[N];
  int str[N];
  int sa[N], t[N], t2[N], c[N], n;
  int rank[N], h[N];
  vector<int> vec[N];
  struct ST {
    int d[N][17];
    int n;
    void init(int n, int* A) {
      this->n = n;
      for (int i = 1; i <= n; i++) d[i][0] = A[i];
      for (int j = 1; j <= Log[n]; j++)
        for (int i = 1; i + (1 << j) - 1 <= n; i++)
          d[i][j] = min(d[i][j - 1], d[i + (1 << j - 1)][j - 1]);
    }
    int query(int st, int ed) {
      int m = Log[ed - st + 1];
      return min(d[st][m], d[ed - (1 << m) + 1][m]);
    }
  } rmq;
  void init(int* str, int len) {
    for (int i = 0; i < (int)(len); i++) s[i] = str[i];
    n = len;
    s[n] = 0;
  }
  void geth() {
    int i, j, k = 0;
    for (i = 0; i < n; i++) rank[sa[i]] = i;
    for (i = 0; i < n; i++) {
      if (k) k--;
      if (!rank[i]) continue;
      j = sa[rank[i] - 1];
      while (s[i + k] == s[j + k]) k++;
      h[rank[i]] = k;
    }
    rmq.init(n - 1, h);
  }
  void build(int m) {
    int i, *x = t, *y = t2;
    for (i = 0; i < m; i++) c[i] = 0;
    for (i = 0; i < n; i++) c[x[i] = s[i]]++;
    for (i = 1; i < m; i++) c[i] += c[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--c[x[i]]] = i;
    for (int k = 1; k <= n; k <<= 1) {
      int p = 0;
      for (i = n - k; i < n; i++) y[p++] = i;
      for (i = 0; i < n; i++)
        if (sa[i] >= k) y[p++] = sa[i] - k;
      for (i = 0; i < m; i++) c[i] = 0;
      for (i = 0; i < n; i++) c[x[y[i]]]++;
      for (i = 1; i < m; i++) c[i] += c[i - 1];
      for (i = n - 1; i >= 0; i--) sa[--c[x[y[i]]]] = y[i];
      swap(x, y);
      p = 1, x[sa[0]] = 0;
      for (i = 1; i < n; i++) {
        if (y[sa[i]] != y[sa[i - 1]])
          x[sa[i]] = p++;
        else if (sa[i] < n - k && sa[i - 1] < n - k)
          x[sa[i]] = y[sa[i] + k] == y[sa[i - 1] + k] ? p - 1 : p++;
        else
          x[sa[i]] = p++;
      }
      if (p >= n) break;
      m = p;
    }
    geth();
  }
  int lcp(int st, int ed) {
    if (st == ed) return n - st;
    int a = rank[st];
    int b = rank[ed];
    if (a > b) swap(a, b);
    return rmq.query(a + 1, b);
  }
  void run() {
    memset(last, -1, sizeof(last));
    for (int i = 0; i < (int)(sum); i++) {
      int j = sa[i];
      pre[i] = last[sor[j]];
      last[sor[j]] = i;
    }
    setup(1, 0, sum - 1);
  }
  int solve(int p, int len) {
    int lt, rt, L, R;
    int r = rank[p];
    L = 0, R = r;
    while (L <= R) {
      int mid = L + R >> 1;
      if (lcp(sa[mid], p) >= len)
        R = mid - 1;
      else
        L = mid + 1;
    }
    lt = L;
    L = r, R = sum - 1;
    while (L <= R) {
      int mid = L + R >> 1;
      if (lcp(sa[mid], p) >= len)
        L = mid + 1;
      else
        R = mid - 1;
    }
    rt = R;
    if (p == 0 && len == 1)
      ;
    return query(1, 0, sum - 1, lt, rt, lt);
  }
  void gao(int id) {
    long long res = 0;
    int rt = pos[id];
    int ed = 0;
    for (int i = 0; i < (int)(leng[id]); i++) {
      int j = rt + i;
      if (ed < i) ed = i;
      while (ed < leng[id] && solve(j, ed - i + 1) >= K) ed++;
      res += ed - i;
    }
    printf("%I64d ", res);
  }
} sol;
int main() {
  init();
  scanf("%d%d", &m, &K);
  int rt = 0;
  int vv = 150;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%s", ss + rt);
    int len = strlen(ss + rt);
    sum += len;
    for (int j = 0; j < (int)(len); j++) {
      arr[j + rt] = ss[j + rt];
      sor[j + rt] = i;
    }
    pos[i] = rt;
    leng[i] = len;
    arr[rt + len] = vv++;
    sor[rt + len] = i + m;
    len++;
    rt += len;
  }
  sol.init(arr, rt);
  sol.build(vv);
  sol.run();
  for (int i = 0; i < (int)(m); i++) sol.gao(i);
  puts("");
  return 0;
}
