#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000009);
int n, m;
int pos;
char seq[11];
int des[101][26], nxt[101], q[100], depth[101], lEnd[101], dp[1001][101][10];
int Insert(const char* const p) {
  int l, now(0);
  for (l = 0; p[l]; ++l)
    if (des[now][p[l] - 'A'])
      now = des[now][p[l] - 'A'];
    else {
      des[now][p[l] - 'A'] = ++pos;
      depth[pos] = l + 1;
      now = pos;
    }
  lEnd[now] = l;
  return l;
}
void Build(void) {
  int l(0), r(0), now;
  for (int i = 0; i < 26; ++i) des[0][i] && (q[r++] = des[0][i]);
  while (l < r) {
    now = q[l];
    for (int i = 0; i < 26; ++i) {
      int& t(des[now][i]);
      if (t) {
        nxt[t] = des[nxt[now]][i];
        q[r++] = t;
      } else
        t = des[nxt[now]][i];
    }
    ++l;
  }
  for (int i = 0; i < r; ++i) {
    int t(q[i]);
    lEnd[t] < lEnd[nxt[t]] && (lEnd[t] = lEnd[nxt[t]]);
  }
  return;
}
int main() {
  int maxl(0), t1, t2, t3, ans(0);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%s", seq);
    t1 = Insert(seq);
    maxl < t1 && (maxl = t1);
  }
  Build();
  dp[0][0][0] = 1;
  for (int l = 1; l <= n; ++l)
    for (int stat = 0; stat <= pos; ++stat)
      for (int rem = 0; rem < maxl; ++rem) {
        if (!dp[l - 1][stat][rem]) continue;
        for (int c = 0; c < 26; ++c) {
          t1 = des[stat][c];
          if (!t1) continue;
          t2 = depth[t1];
          if (!lEnd[stat] && t2 < rem + 1) continue;
          t3 = lEnd[t1] >= rem + 1 ? 0 : rem + 1;
          if (t3 == maxl) continue;
          dp[l][t1][t3] += dp[l - 1][stat][rem];
          dp[l][t1][t3] >= MOD && (dp[l][t1][t3] -= MOD);
        }
      }
  for (int i = 0; i <= pos; ++i)
    if (lEnd[i]) {
      ans += dp[n][i][0];
      ans >= MOD && (ans -= MOD);
    }
  printf("%d\n", ans);
  return 0;
}
