#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define IS_INF(x) (std::isinf(x))
#define IS_NAN(x) (std::isnan(x))
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define __builtin_popcount __builtin_popcountll
using namespace std;
template<class X, class Y>
bool minimize(X &x, const Y &y) {
X eps = 1e-9;
if (x > y + eps) {
x = y;
return true;
} else return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
return true;
} else return false;
}
template<class T>
T Abs(const T &x) {
return (x < 0 ? -x : x);
}
/* Author: Van Hanh Pham */
/** END OF TEMPLATE - ACTUAL SOLUTION COMES HERE **/
const int INF = (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
void add(int &x, const int &y) {
x += y;
if (x >= MOD) x -= MOD;
}
#define MAX_GROUP 111
struct Node {
Node *child[26];
bool hasWord;
int numWord;
pair<int, int> dp[MAX_GROUP];
Node() {
REP(i, 26) child[i] = NULL;
hasWord = false;
numWord = 0;
}
};
Node *root;
int numWord, numGroup;
int comb[MAX_GROUP][MAX_GROUP], frac[MAX_GROUP];
void init(void) {
cin >> numWord >> numGroup;
root = new Node();
REP(love, numWord) {
string word; cin >> word;
Node *p = root;
FORE(it, word) {
Node *&child = p->child[*it - 'A'];
if (child == NULL) child = new Node();
p = child;
}
p->hasWord = true;
p->numWord = 1;
}
FOR(i, 1, numGroup) {
comb[i][0] = 0;
comb[0][i] = 1;
}
comb[0][0] = 1;
FOR(i, 1, numGroup) FOR(j, 1, numGroup) {
if (i > j) comb[i][j] = 0;
if (i == j) comb[i][j] = 1;
if (i < j) comb[i][j] = (comb[i][j - 1] + comb[i - 1][j - 1]) % MOD;
}
frac[0] = 1;
FOR(i, 1, numGroup) frac[i] = 1LL * frac[i - 1] * i % MOD;
}
void update(pair<int, int> &cur, const pair<int, int> &tmp) {
if (maximize(cur.fi, tmp.fi)) cur.se = tmp.se;
else if (cur.fi == tmp.fi) add(cur.se, tmp.se);
}
int countMerge(int x, int y, int z) {
int t = x + y - z;
return 1LL * comb[t][x] * comb[t][y] % MOD * frac[t] % MOD;
}
pair<int, int> best[MAX_GROUP], prevBest[MAX_GROUP];
void dfs(Node *p) {
REP(i, 26) if (p->child[i] != NULL) dfs(p->child[i]);
REP(i, numGroup + 1) best[i] = {-INF, 0};
if (p->hasWord) best[1] = {0, 1};
else best[0] = {0, 1};
REP(i, 26) if (p->child[i] != NULL) {
Node *ch = p->child[i];
REP(j, min(p->numWord, numGroup) + 1) {
prevBest[j] = best[j];
best[j] = {-INF, 0};
}
REP(x, min(p->numWord, numGroup) + 1) REP(y, min(ch->numWord, numGroup) + 1)
FOR(z, max(x, y), min(x + y, numGroup)) {
int numNode = prevBest[x].fi + ch->dp[y].fi;
int numWay = 1LL * prevBest[x].se * ch->dp[y].se % MOD * countMerge(x, y, z) % MOD;
update(best[z], {numNode, numWay});
}
p->numWord += ch->numWord;
}
FOR(i, 1, numGroup) p->dp[i] = i <= p->numWord ? make_pair(best[i].fi + i, best[i].se) : make_pair(-INF, 0);
}
void process(void) {
dfs(root);
cout << root->dp[numGroup].fi << " " << 1LL * root->dp[numGroup].se * frac[numGroup] % MOD << endl;
}
int main(void) {
#ifdef ONLINE_JUDGE
freopen("trie.inp", "r", stdin);
freopen("trie.out", "w", stdout);
#endif // ONLINE_JUDGE
init();
process();
return 0;
}
/*** LOOK AT MY CODE. MY CODE IS AMAZING :D ***/
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBGT1IoaSwgYSwgYikgZm9yIChpbnQgaSA9IChhKSwg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