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BD>3232λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3232λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊλʾͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>2626λ<EFBFBD><EFBFBD>Ӧ2626<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>ֻ򲻳<EFBFBD><EFBFBD>ּ<EFBFBD><EFBFBD>ɡ<EFBFBD>*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 18;
const int mod = 998244353;
int n, L, mask[18];
char s[18][27];
ll ans;
ll qpow(ll a, ll b)
{
ll re = 1;
while (b != 0)
{
if ((b & 1) == 1)
re = re * a % mod;
a = a * a % mod;
b >>= 1;
}
return re;
}
int Count(int x)
{
int cnt = 0;
while (x != 0)
{
if ((x & 1) == 1)
cnt++;
x >>= 1;
}
return cnt;
}
int main()
{
scanf("%d%d", &n, &L);
for (int i = 0; i < n; i++)
{
scanf("%s", s[i]);
for (int j = 0; s[i][j] != '\0'; j++)
mask[i] |= (1 << (s[i][j] - 'a'));
}
for (int i = 1; i < (1 << n); i++)
{
int ch = (1 << 26) - 1, cnt = 0;
for (int j = 0; j < n; j++)
if (((1 << j)&i) != 0)
cnt++, ch &= mask[j];
if ((cnt & 1) == 1)
ans = (ans + qpow(Count(ch), L)) % mod;
else
ans = (ans + (mod - qpow(Count(ch), L)) % mod) % mod;
}
printf("%lld\n", ans);
return 0;
}