#include <bits/stdc++.h>
#include<vector>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define ull unsigned long long
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6+5, mod = 998244353;
int n, k, id[N*26], cnt[N];
ll lv[45], f[N*26];
struct node {
unordered_map <int, int> ch;
int sz, len, fa;
}v[N*26];
vector <int> pr;
int las, tot, o[45];
inline int tr (int p, int k) { return k > v[p].sz ? 0 : k; }
void upd (int k) {
// cout << "INS:" << k << endl;
int p = las, cur = ++tot;
v[cur].sz = v[p].sz+(tr(p, k) == 0); v[cur].len = v[p].len+1;
// cout << "NEW:" << cur << " " << v[cur].sz << " " << "CHECK_FA:" << las << " " << v[las].fa << endl;
// cout << "CHECK:" << v[2].sz << endl ;
las = cur;
while (p && !v[p].ch.count(tr(p, k))) {
// cout << p << " " << v[p].sz << " " << v[cur].sz << endl;
if (v[p].sz+(tr(p, k) == 0) < v[cur].sz) {
int nc = ++tot;
v[nc].sz = v[p].sz+(tr(p, k) == 0); v[nc].len = v[p].len+1;
v[cur].fa = nc; cur = nc;
}
// cout << "EDGE:" << p << " " << tr(p, k) << " " << cur << endl;
v[p].ch[tr(p, k)] = cur;
p = v[p].fa;
}
if (!p) return v[cur].fa = 1, void();
int q = v[p].ch[tr(p, k)];
if (v[q].len == v[p].len+1) return v[cur].fa = q, void();
int cl = ++tot; v[cl] = v[q]; v[cl].sz = v[p].sz+(tr(p, k) == 0); v[cl].len = v[p].len+1; v[q].fa = v[cur].fa = cl;
while (p && v[p].ch.count(tr(p, k)) && v[p].ch[tr(p, k)] == q) v[p].ch[tr(p, k)] = cl, p = v[p].fa;
}
string str;
void solve () {
cin >> n >> k;
lv[0] = 1; for (int i = 1;i < k;i++) lv[i] = lv[i-1]*(k-i)%mod;
ll s = k, ans = 0;
for (int i = 1;i <= n;i++) {
while (tot) {
v[tot].ch.clear();
v[tot].sz = v[tot].len = v[tot].fa = 0;
tot--;
}
las = tot = 1;
pr.clear(); memset(o, 0, sizeof o);
cin >> str;
for (char j : str) {
int x = j-'a';
if (o[x]) {
int id = 0;
for (int p = pr.size()-1;~p;p--) if (pr[p] == x) {
id = p; break;
}
upd(pr.size()-id);
pr.erase(pr.begin()+id); pr.push_back(x);
}
else {
upd(0); pr.push_back(x); o[x] = 1;
}
}
memset(f, 0, tot+1<<3);
// cout << s << " " << v[1].ch[0] << " " << tot << endl;
for (auto j : v[1].ch) f[j.se] = s; s = 0;
memset(cnt, 0, str.size()+1<<2);
for (int j = 2;j <= tot;j++) ++cnt[v[j].len];
for (int j = 1;j <= str.size();j++) cnt[j] += cnt[j-1];
for (int j = 2;j <= tot;j++) id[cnt[v[j].len]--] = j;
for (int J = 1;J < tot;J++) {
int j = id[J]; (ans += lv[v[j].sz-1]*f[j]) %= mod;
// cout << "F:" << j << " " << f[j] << " " << v[j].sz << " " << v[j].len << endl;
for (auto p : v[j].ch) (f[p.se] += f[j]) %= mod; //, cout << p.se << " ";
// cout << endl;
if (v[j].ch.count(0)) (s += f[j]*lv[v[j].sz-1]%mod*(v[j].sz+1-v[j].ch.size())) %= mod;
else (s += f[j]*lv[v[j].sz-1]%mod*(k-v[j].ch.size())) %= mod;
}
// cout << ans << endl;
}
cout << (ans+mod+1)%mod;
}
signed main () {
// ios::sync_with_stdio(0);
// cin.tie(0); cout.tie(0);
int T = 1;
while (T--) solve();
return 0;
}