"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>
int is_same(char a[], char b[], int len) {
  int i;
  for (i = 0; i < len; i++)
    if (a[i] != b[i]) return 0;
  return 1;
}
int n, lim;
char in[12][12];
int len[12];
int dp[1011][12][12][12];
char *digit = "ACGT";
int edge1[12][12][12][4];
int edge2[12][12][12][4];
int edge3[12][12][12][4];
void edge_generator(void) {
  int i, j, k;
  int word, word_len, ok_len;
  int next_word, next_word_len, next_ok_len;
  int fin, match, ok_chk;
  char now[120];
  int now_len;
  int mx;
  for (word = 0; word < n; word++)
    for (word_len = 0; word_len < len[word]; word_len++)
      for (ok_len = 0; ok_len < word_len + 1; ok_len++)
        for (k = 0; k < 4; k++) {
          fin = 0;
          for (i = 0; i < word_len; i++) now[i] = in[word][i];
          now[word_len] = digit[k];
          now_len = word_len + 1;
          match = 0;
          for (i = 0; i < n; i++)
            if (now_len >= len[i])
              if (ok_len + len[i] >= now_len) {
                if (is_same(in[i], now + now_len - len[i], len[i])) match = 1;
              }
          next_word = 0;
          next_word_len = 0;
          next_ok_len = 0;
          if (match) fin = 1;
          for (i = 0; i < n; i++)
            for (j = 1; j < len[i]; j++) {
              if (next_word_len >= j) continue;
              if (is_same(in[i], now + now_len - j, j) == 0) continue;
              if (match)
                ok_chk = j;
              else
                ok_chk = ok_len - (now_len - j);
              if (ok_chk < 0) continue;
              fin = 1;
              next_word = i;
              next_word_len = j;
              next_ok_len = ok_chk;
            }
          if (fin == 0) {
            edge1[word][word_len][ok_len][k] = -1;
            continue;
          }
          edge1[word][word_len][ok_len][k] = next_word;
          edge2[word][word_len][ok_len][k] = next_word_len;
          edge3[word][word_len][ok_len][k] = next_ok_len;
        }
}
int solve(int depth, int word, int word_len, int ok_len) {
  int i, j, k;
  int next_word, next_word_len, next_ok_len;
  int res = 0;
  if (dp[depth][word][word_len][ok_len] >= 0)
    return dp[depth][word][word_len][ok_len];
  if (depth == lim) {
    if (word_len == ok_len) res++;
    return dp[depth][word][word_len][ok_len] = res;
  }
  for (k = 0; k < 4; k++) {
    if (edge1[word][word_len][ok_len][k] < 0) continue;
    next_word = edge1[word][word_len][ok_len][k];
    next_word_len = edge2[word][word_len][ok_len][k];
    next_ok_len = edge3[word][word_len][ok_len][k];
    res += solve(depth + 1, next_word, next_word_len, next_ok_len);
    res %= 1000000009;
  }
  return dp[depth][word][word_len][ok_len] = res;
}
int main() {
  int i, j, k, l, m, res;
  while (scanf("%d%d", &lim, &n) == 2) {
    for (i = 0; i < n; i++) scanf("%s", in[i]);
    for (i = 0; i < n; i++) {
      for (j = 0;; j++)
        if (in[i][j] < ' ') break;
      len[i] = j;
    }
    for (i = 0; i < 1011; i++)
      for (j = 0; j < 12; j++)
        for (k = 0; k < 12; k++)
          for (l = 0; l < 12; l++) dp[i][j][k][l] = -1;
    edge_generator();
    res = solve(0, 0, 0, 0);
    printf("%d\n", res);
  }
  return 0;
}
