#include <bits/stdc++.h>
#define NAME "GENEMAP"
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i,a ,b) for(int i = (a), _b = (b); i >= _b; --i)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define ull unsigned long long
using namespace std;
const ll mod = 1e9 + 7;
const int maxN = 1e5 + 10;
int n, k;
string s;
ull h, _h, hh;
typedef pair<ull, ull> ii;
ull a[maxN], b[maxN];
ll gt[maxN], ans1, ans2;
int numa, numb;
void io()
{
	freopen(NAME".inp", "r", stdin);
	freopen(NAME".out", "w", stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);
}
ll Pow(ll cs, ll sm)
{
	if(sm == 1) return cs%mod;
	ll c = Pow(cs, sm / 2)%mod;
	if(sm%2) return ((c * c)%mod * cs)%mod;
	return (c * c)%mod;
}
ll ckn(ll n, ll k)
{
	return (gt[n]%mod * Pow(((gt[k]%mod * gt[n - k])%mod), mod - 2) % mod)%mod;
}
int main()
{
	io();
	cin >> n >> k;
	gt[0] = 1;
	FOR(i, 1, maxN - 10) gt[i] = (gt[i - 1]%mod * i)%mod;
	FOR(i, 1, n)
	{
		cin >> s;
		if(s.size() < k) continue;
		h = 0, _h = 0, hh = 0;
		FOR(j, 0, k - 1) h = h * 26 + s[j] - 'a' + 1;
		_h = h;
		FOR(j, s.size() - k, s.size() - 1) h = h * 26 + s[j] - 'a' + 1;
		a[++numa] = h;
		if(s.size() < k + 1) continue;
		_h = _h * 26 + s[k] - 'a' + 1;
		FOR(j, s.size() - k - 1, s.size() - 1) _h = _h * 26 + s[j] - 'a' + 1;
		b[++numb] = _h;
	}
	sort(a + 1, a + numa + 1);
	sort(b + 1, b + numb + 1);
	FOR(i, 1, numa)
	{
		if(a[i] == a[i - 1]) continue;
		int id = upper_bound(a + 1, a + numa + 1, a[i]) - a;
		ans1 = (ans1%mod + ckn(id - i, 2)%mod)%mod;
	}
	FOR(i, 1, numb)
	{
		if(b[i] == b[i - 1]) continue;
		int id = upper_bound(b + 1, b + numb + 1, b[i]) - b;
		ans2 = (ans2 % mod + ckn(id - i, 2)%mod) % mod;
	}
	if(ans1 - ans2 < 0) cout << (ans1 - ans2 + mod * mod)%mod;
	else cout << ans1 - ans2;
	return 0;
}