#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100, Mod = 1e9 + 9;
int Add(int x, int y) {
  x += y;
  return x >= Mod ? x - Mod : x;
}
int chk(char s) { return s == 'A' ? 0 : (s == 'C' ? 1 : (s == 'G' ? 2 : 3)); }
struct ACAM {
  int rt, siz, fail[MAXN + 5], trs[MAXN + 5][4];
  int mxlen[MAXN + 5];
  vector<int> Graph[MAXN + 5];
  ACAM() {
    rt = ++siz;
    for (int i = 0; i < 4; i++) trs[0][i] = 1;
  }
  void Insert(int len, char *str) {
    int u = rt;
    for (int i = 1; i <= len; i++) {
      if (!trs[u][chk(str[i])]) trs[u][chk(str[i])] = ++siz;
      u = trs[u][chk(str[i])];
    }
    mxlen[u] = len;
  }
  void Build() {
    queue<int> Que;
    Que.push(rt);
    while (!Que.empty()) {
      int u = Que.front();
      Que.pop();
      for (int i = 0; i < 4; i++) {
        if (trs[u][i]) {
          fail[trs[u][i]] = trs[fail[u]][i];
          Que.push(trs[u][i]);
        } else
          trs[u][i] = trs[fail[u]][i];
      }
      mxlen[u] = max(mxlen[u], mxlen[fail[u]]);
    }
  }
  int dp[1005][15][MAXN + 5];
  int Dp(int n) {
    dp[0][0][1] = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j <= 10; j++)
        for (int u = 1; u <= siz; u++)
          for (int p = 0, v; p < 4; p++)
            if (v = trs[u][p]) {
              if (mxlen[v] > j)
                dp[i + 1][0][v] = Add(dp[i + 1][0][v], dp[i][j][u]);
              else
                dp[i + 1][j + 1][v] = Add(dp[i + 1][j + 1][v], dp[i][j][u]);
            }
    int Ans = 0;
    for (int i = 1; i <= siz; i++) Ans = Add(Ans, dp[n][0][i]);
    return Ans;
  }
} ACAM;
int n, m;
char str[MAXN + 5];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%s", str + 1);
    int len = strlen(str + 1);
    ACAM.Insert(len, str);
  }
  ACAM.Build();
  printf("%d\n", ACAM.Dp(n));
  return 0;
}
