"Multidimensional spaces are completely out of style these days, unlike genetics problems" — thought physicist Woll and changed his subject of study to bioinformatics. Analysing results of sequencing he faced the following problem concerning DNA sequences. We will further think of a DNA sequence as an arbitrary string of uppercase letters "A", "C", "G" and "T" (of course, this is a simplified interpretation).

Let w be a long DNA sequence and s1, s2, ..., sm — collection of short DNA sequences. Let us say that the collection filters w iff w can be covered with the sequences from the collection. Certainly, substrings corresponding to the different positions of the string may intersect or even cover each other. More formally: denote by |w| the length of w, let symbols of w be numbered from 1 to |w|. Then for each position i in w there exist pair of indices l, r (1 ≤ l ≤ i ≤ r ≤ |w|) such that the substring w[l ... r] equals one of the elements s1, s2, ..., sm of the collection.

Woll wants to calculate the number of DNA sequences of a given length filtered by a given collection, but he doesn't know how to deal with it. Help him! Your task is to find the number of different DNA sequences of length n filtered by the collection {si}.

Answer may appear very large, so output it modulo 1000000009.

Input

First line contains two integer numbers n and m (1 ≤ n ≤ 1000, 1 ≤ m ≤ 10) — the length of the string and the number of sequences in the collection correspondently. 

Next m lines contain the collection sequences si, one per line. Each si is a nonempty string of length not greater than 10. All the strings consist of uppercase letters "A", "C", "G", "T". The collection may contain identical strings.

Output

Output should contain a single integer — the number of strings filtered by the collection modulo 1000000009 (109 + 9).

Examples

Input

2 1
A


Output

1


Input

6 2
CAT
TACT


Output

2

Note

In the first sample, a string has to be filtered by "A". Clearly, there is only one such string: "AA".

In the second sample, there exist exactly two different strings satisfying the condition (see the pictures below).

<image> <image>
#include <bits/stdc++.h>
using namespace std;
struct fastIO {
  inline fastIO operator>>(int& num) {
    num = 0;
    char c = getchar();
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    bool foo = 0;
    if (c == '-') {
      foo = 1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') {
      num = (num << 3) + (num << 1) + c - '0';
      c = getchar();
    }
    if (foo) num = -num;
    return *this;
  }
  inline fastIO operator>>(long long& num) {
    num = 0;
    char c = getchar();
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    bool foo = 0;
    if (c == '-') {
      foo = 1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') {
      num = (num << 3) + (num << 1) + c - '0';
      c = getchar();
    }
    if (foo) num = -num;
    return *this;
  }
  inline fastIO operator>>(float& num) {
    scanf("%f", &num);
    return *this;
  }
  inline fastIO operator>>(double& num) {
    scanf("%lf", &num);
    return *this;
  }
  inline fastIO operator>>(long double& num) {
    scanf("%Lf", &num);
    return *this;
  }
  inline fastIO operator>>(char& num) {
    num = getchar();
    while (num == ' ' || num == '\n') num = getchar();
    return *this;
  }
  inline fastIO operator>>(char* num) {
    int cnt = 0;
    char c = getchar();
    while (c == ' ' || c == '\n') c = getchar();
    while (c != ' ' && c != '\n') {
      num[cnt++] = c;
      c = getchar();
    }
    num[cnt] = 0;
    return *this;
  }
  inline fastIO operator>>(string& num) {
    cin >> num;
    return *this;
  }
  inline void printInt(const int& num) {
    if (num < 10) {
      putchar(num + '0');
      return;
    }
    printInt(num / 10);
    putchar((num % 10) + '0');
  }
  inline void printINT(const long long& num) {
    if (num < 10) {
      putchar(num + '0');
      return;
    }
    printINT(num / 10);
    putchar((num % 10) + '0');
  }
  inline fastIO operator<<(const int& num) {
    if (num < 0)
      putchar('-'), printInt(-num);
    else
      printInt(num);
    return *this;
  }
  inline fastIO operator<<(const long long& num) {
    if (num < 0)
      putchar('-'), printINT(-num);
    else
      printINT(num);
    return *this;
  }
  inline fastIO operator<<(const float& num) {
    printf("%.10f", num);
    return *this;
  }
  inline fastIO operator<<(const double& num) {
    printf("%.16lf", num);
    return *this;
  }
  inline fastIO operator<<(const long double& num) {
    printf("%.20Lf", num);
    return *this;
  }
  inline fastIO operator<<(const char& num) {
    putchar(num);
    return *this;
  }
  inline fastIO operator<<(const char* num) {
    for (int i = 0; num[i]; i++) putchar(num[i]);
    return *this;
  }
  inline fastIO operator<<(const string& num) {
    cout << num;
    return *this;
  }
} fio;
namespace ac {
int cnt;
int tag[105];
int fail[105];
int nei[105][4];
void init() {
  tag[0] = 0;
  memset((void*)nei[0], -1, sizeof(nei[0]));
  cnt = 1;
}
void add(int m, int* s, int t) {
  int now = 0;
  for (int i = 0; i < m; i++) {
    if (nei[now][s[i]] == -1) {
      tag[cnt] = 0;
      memset((void*)nei[cnt], -1, sizeof(nei[cnt]));
      nei[now][s[i]] = cnt++;
    }
    now = nei[now][s[i]];
  }
  tag[now] = t;
}
void build() {
  queue<int> q;
  fail[0] = 0;
  for (int i = 0; i < 4; i++) {
    if (nei[0][i] != -1) {
      fail[nei[0][i]] = 0;
      q.push(nei[0][i]);
    } else {
      nei[0][i] = 0;
    }
  }
  while (((int)(q).size())) {
    int x = q.front();
    q.pop();
    tag[x] = max(tag[x], tag[fail[x]]);
    for (int i = 0; i < 4; i++) {
      if (nei[x][i] != -1) {
        fail[nei[x][i]] = nei[fail[x]][i];
        q.push(nei[x][i]);
      } else {
        nei[x][i] = nei[fail[x]][i];
      }
    }
  }
}
}  // namespace ac
int n, m;
long long dp[1005][105][15];
char pat[] = "ACGT";
char tmp[105];
int tmp2[105];
int main() {
  fio >> n >> m;
  ac::init();
  for (int i = 0; i < m; i++) {
    fio >> tmp;
    int len = strlen(tmp);
    for (int j = 0; j < len; j++) {
      tmp2[j] = strchr(pat, tmp[j]) - pat;
    }
    ac::add(len, tmp2, len);
  }
  ac::build();
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < ac::cnt; j++) {
      for (int k = 0; k < 15; k++) {
        if (!dp[i][j][k]) {
          continue;
        }
        for (int l = 0; l < 4; l++) {
          int go = ac::nei[j][l];
          if (ac::tag[go] > k) {
            dp[i + 1][go][0] = (dp[i + 1][go][0] + dp[i][j][k]) % 1000000009;
          } else if (k < 14) {
            dp[i + 1][go][k + 1] =
                (dp[i + 1][go][k + 1] + dp[i][j][k]) % 1000000009;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < ac::cnt; i++) {
    ans = (ans + dp[n][i][0]) % 1000000009;
  }
  fio << ans << '\n';
  return 0;
}
