#include <bits/stdc++.h>
using namespace std;
int ch[101][4], b[101], fa[101], mx[101], tot, n, m, ans, f[1001][101][11];
char s[200];
struct AC {
  int p;
  void insert(char *s) {
    int l = strlen(s);
    p = 0;
    for (int i = 0; i < l; i++) {
      int id = s[i] == 'A' ? 0 : (s[i] == 'C' ? 1 : (s[i] == 'T' ? 2 : 3));
      if (!ch[p][id]) ch[p][id] = ++tot;
      p = ch[p][id];
    }
    b[p] = l;
  }
  void getfail() {
    queue<int> q;
    for (int i = 0; i < 4; i++)
      if (ch[0][i]) q.push(ch[0][i]), mx[ch[0][i]] = b[ch[0][i]];
    while (!q.empty()) {
      int r = q.front();
      q.pop();
      for (int i = 0; i < 4; i++) {
        int u = ch[r][i], v = fa[r];
        if (!u) {
          ch[r][i] = ch[v][i];
          continue;
        }
        q.push(u);
        while (v && !ch[v][i]) v = fa[v];
        fa[u] = ch[v][i];
        mx[u] = max(mx[fa[u]], b[u]);
      }
    }
  }
} ac;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    ac.insert(s);
  }
  ac.getfail();
  f[0][0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= tot; j++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 4; c++)
          if (ch[j][c]) {
            if (mx[ch[j][c]] >= k + 1)
              (f[i + 1][ch[j][c]][0] += f[i][j][k]) %= 1000000009;
            else
              (f[i + 1][ch[j][c]][k + 1] += f[i][j][k]) %= 1000000009;
          }
  for (int i = 0; i <= tot; i++) (ans += f[n][i][0]) %= 1000000009;
  printf("%d\n", ans);
}
