#include <bits/stdc++.h>
int n, m, t[105][4], p, f[105], d[105], best[105], q[105], l, h, cor[128],
    dp[1005][105][11], ans;
char s[1005];
bool w[105], v[1005][105][11];
int dfs(int x, int y, int z) {
  if (x == n) return y && d[y] == z;
  if (v[x][y][z]) return dp[x][y][z];
  v[x][y][z] = 1;
  int a = 0;
  for (int i = (0); i < (4); i++) {
    int j = y, dep = z;
    while (j && !t[j][i]) {
      dep -= d[j] - d[f[j]];
      j = f[j];
    }
    if (dep < 0 || !t[j][i]) continue;
    j = t[j][i];
    if (dep + best[j] >= d[j]) dep = d[j];
    a = (a + dfs(x + 1, j, dep)) % 1000000009;
  }
  return dp[x][y][z] = a;
}
int main() {
  cor['A'] = 0;
  cor['C'] = 1;
  cor['G'] = 2;
  cor['T'] = 3;
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); i++) {
    scanf("%s", s);
    int r = 0;
    for (int j = 0; s[j]; j++) {
      if (!t[r][cor[s[j]]]) t[r][cor[s[j]]] = ++p;
      r = t[r][cor[s[j]]];
    }
    w[r] = 1;
  }
  q[h++] = 0;
  while (l < h) {
    int y = q[l++];
    if (w[y])
      best[y] = d[y];
    else
      best[y] = best[f[y]];
    for (int i = (0); i < (4); i++)
      if (t[y][i]) {
        if (y) {
          int x = f[y];
          while (x && !t[x][i]) x = f[x];
          if (t[x][i]) x = t[x][i];
          f[t[y][i]] = x;
        }
        d[t[y][i]] = d[y] + 1;
        q[h++] = t[y][i];
      }
  }
  printf("%d\n", dfs(0, 0, 0));
}
