#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
int trans(char s) {
  if (s == 'A') return 0;
  if (s == 'C') return 1;
  if (s == 'G') return 2;
  if (s == 'T') return 3;
  return -1;
}
int n, m;
struct ACAutomaton {
  int tr[1005][4], tot = 1, fail[1005], dep[1005], epdep[1005], upper;
  bool ep[1005];
  void insert(char *str) {
    int len = strlen(str + 1), root = 1;
    upper = max(upper, len);
    for (int i = 1; i <= len; ++i) {
      int u = trans(str[i]);
      if (!tr[root][u]) tr[root][u] = ++tot;
      dep[tr[root][u]] = dep[root] + 1;
      root = tr[root][u];
    }
    ep[root] = true;
    epdep[root] = dep[root];
  }
  void buildFail() {
    ep[0] = true;
    for (int i = 0; i <= 3; ++i) tr[0][i] = 1;
    queue<int> Q;
    Q.push(1);
    while (!Q.empty()) {
      int now = Q.front();
      Q.pop();
      for (int i = 0; i <= 3; ++i) {
        if (tr[now][i]) {
          fail[tr[now][i]] = tr[fail[now]][i];
          if (ep[tr[fail[now]][i]]) ep[tr[now][i]] = ep[tr[fail[now]][i]];
          Q.push(tr[now][i]);
        } else
          tr[now][i] = tr[fail[now]][i];
      }
      epdep[now] = max(epdep[now], epdep[fail[now]]);
    }
  }
  int dp[1005][1005][15];
  int Dp() {
    dp[1][0][0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= upper; ++j) {
        for (int k = 1; k <= tot; ++k) {
          for (int l = 0; l <= 3; ++l) {
            int v = tr[k][l];
            if (epdep[v] > j)
              (dp[v][i + 1][0] += dp[k][i][j]) %= MOD;
            else
              (dp[v][i + 1][j + 1] += dp[k][i][j]) %= MOD;
          }
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= tot; ++i) (ans += dp[i][n][0]) %= MOD;
    return ans;
  }
} AC;
char s[15];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%s", s + 1), AC.insert(s);
  AC.buildFail();
  printf("%d", AC.Dp());
  return 0;
}
