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;
long long a, b, c, sa[200001], id[200001], cnt[200001], rk[200001], rk1[200001],
    ht[200001], m[200001], cn, len, ans[200001], le[200001], s1[200001];
string s;
struct p {
  long long q, w, e;
};
struct pp {
  long long mi;
} l[1000001];
vector<p> qu;
deque<p> quu;
void SA() {
  len = a + 'z' + 1;
  for (int i = 1; i <= c; i++) {
    cnt[s1[i - 1]]++;
    rk[i] = s1[i - 1];
  }
  for (int i = 1; i <= len; i++) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = c; i >= 1; i--) {
    sa[cnt[rk[i]]] = i;
    cnt[rk[i]]--;
  }
  for (int ii = 1;; ii <<= 1) {
    cn = 0;
    for (int i = c; i > c - ii; i--) {
      id[++cn] = i;
    }
    for (int i = 1; i <= c; i++) {
      if (sa[i] > ii) {
        id[++cn] = sa[i] - ii;
      }
    }
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= c; i++) {
      cnt[rk[id[i]]]++;
    }
    for (int i = 1; i <= len; i++) {
      cnt[i] += cnt[i - 1];
    }
    for (int i = c; i >= 1; i--) {
      sa[cnt[rk[id[i]]]] = id[i];
      cnt[rk[id[i]]]--;
    }
    memcpy(rk1, rk, sizeof(rk));
    cn = 0;
    for (int i = 1; i <= c; i++) {
      if (rk1[sa[i]] == rk1[sa[i - 1]] &&
          rk1[sa[i] + ii] == rk1[sa[i - 1] + ii]) {
        rk[sa[i]] = cn;
      } else
        rk[sa[i]] = ++cn;
    }
    len = cn;
    if (len == c) {
      break;
    }
  }
  for (int i = 1; i <= c; i++) {
    sa[rk[i]] = i;
  }
  cn = 0;
  for (int i = 1; i <= c; i++) {
    if (cn) {
      cn--;
    }
    while (s1[cn + i - 1] == s1[cn + sa[rk[i] - 1] - 1]) {
      cn++;
    }
    ht[rk[i]] = cn;
  }
}
void pushup(long long qq) { l[qq].mi = min(l[qq << 1].mi, l[qq << 1 | 1].mi); }
void build(long long x, long long ll, long long rr) {
  if (ll == rr) {
    l[x].mi = ht[ll];
    return;
  }
  long long mid = ((ll + rr) >> 1);
  build(x << 1, ll, mid);
  build(x << 1 | 1, mid + 1, rr);
  pushup(x);
}
long long query(long long x, long long ll, long long rr, long long qq,
                long long ww) {
  if (qq <= ll && rr <= ww) {
    return l[x].mi;
  }
  long long mid = ((ll + rr) >> 1);
  if (mid >= ww) {
    return query(x << 1, ll, mid, qq, ww);
  } else if (mid < qq) {
    return query(x << 1 | 1, mid + 1, rr, qq, ww);
  } else
    return min(query(x << 1, ll, mid, qq, ww),
               query(x << 1 | 1, mid + 1, rr, qq, ww));
}
int main() {
  scanf("%lld%lld", &a, &b);
  long long yy = 0;
  for (int i = 1; i <= a; i++) {
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      s1[j + yy] = s[j] + a + 1;
      le[j + yy + 1] = s.size() - j;
      m[j + yy + 1] = i;
    }
    yy += s.size();
    s1[yy++] = i;
  }
  c = yy;
  SA();
  long long tt = 0;
  yy = 1;
  for (int i = 1; i <= c; i++) {
    if (m[sa[i]] == 0) ht[i] = 0x3f3f3f3f3f3f;
  }
  build(1, 1, c);
  yy = a + 1;
  memset(cnt, 0, sizeof(cnt));
  for (int i = a + 1; i <= c; i++) {
    cnt[m[sa[i]]]++;
    if (cnt[m[sa[i]]] == 1) {
      tt++;
    }
    while (tt >= b) {
      if (tt == b) {
        if (yy + 1 <= i)
          qu.push_back(p{yy, i, query(1, 1, c, yy + 1, i)});
        else
          qu.push_back(p{yy, i, le[sa[i]]});
      }
      if (cnt[m[sa[yy]]] == 1) {
        if (tt == b) break;
        tt--;
      }
      cnt[m[sa[yy]]]--;
      yy++;
    }
  }
  long long oo = 0;
  for (int i = 1; i <= c; i++) {
    if (m[sa[i]] == 0) continue;
    while (!quu.empty() && quu.front().w < i) {
      quu.pop_front();
    }
    while (oo < qu.size() && qu[oo].q <= i) {
      while (!quu.empty() && qu[oo].e > quu.back().e) {
        quu.pop_back();
      }
      quu.push_back(qu[oo]);
      oo++;
    }
    if (!quu.empty()) {
      ans[m[sa[i]]] += quu.front().e;
    }
  }
  for (int i = 1; i <= a; i++) {
    printf("%lld ", ans[i]);
  }
  return 0;
}
