"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;
namespace IO {
const int buffer_size = 1e5 + 5;
char buf[buffer_size], *S, *T;
bool flag_EOF;
inline char read_char() {
  if (S == T) T = (S = buf) + fread(buf, 1, buffer_size, stdin);
  return S != T ? *(S++) : EOF;
}
inline int read_int() {
  int flag = 1;
  char c = read_char();
  while (c < '0' || c > '9') {
    if (c == EOF) {
      flag_EOF = true;
      return 0;
    }
    flag = (c == '-' ? -1 : 1);
    c = read_char();
  }
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + (c ^ 48);
    c = read_char();
  }
  return x * flag;
}
inline void read_string(char *s) {
  char x;
  do {
    x = read_char();
  } while (x < 'A' || x > 'Z');
  int len = 0;
  while (x >= 'A' && x <= 'Z') {
    s[len++] = x;
    x = read_char();
  }
  s[len] = '\0';
}
char fw[buffer_size];
int pw;
inline void flush() { fwrite(fw, 1, pw, stdout); }
inline void write_char(char x) {
  if (pw == buffer_size) {
    flush();
    pw = 0;
  }
  fw[pw++] = x;
}
char st[13];
int top;
inline void write_int(int x) {
  if (!x) {
    write_char('0');
    return;
  }
  if (x < 0) {
    write_char('-');
    x = -x;
  }
  while (x) {
    st[++top] = x % 10 + '0';
    x /= 10;
  }
  while (top > 0) write_char(st[top--]);
}
inline void write_string(const char *s) {
  for (int i = 0; s[i]; ++i) write_char(s[i]);
}
}  // namespace IO
const int P = 1e9 + 9;
inline void add(int &a, int b) { a = a + b - (a + b >= P ? P : 0); }
const int max_tot = 100 + 5;
int tr[max_tot][4], Len[max_tot], fail[max_tot], f[max_tot], tot;
namespace AC {
inline int To_int(char x) {
  return x == 'A' ? 0 : (x == 'C' ? 1 : (x == 'G' ? 2 : 3));
}
inline void insert(const char *s) {
  int cur = 0, len = strlen(s);
  for (int i = 0; i < len; ++i) {
    int v = To_int(s[i]);
    if (!tr[cur][v]) tr[cur][v] = ++tot;
    cur = tr[cur][v];
  }
  Len[cur] = len;
}
int que[max_tot], head, tail;
inline void build() {
  head = 1, tail = 0;
  for (int i = 0; i < 4; ++i) {
    int u = tr[0][i];
    if (u) {
      f[u] = Len[u];
      que[++tail] = u;
    }
  }
  while (head <= tail) {
    int u = que[head++];
    for (int i = 0; i < 4; ++i) {
      int v = tr[u][i];
      if (v) {
        fail[v] = tr[fail[u]][i];
        f[v] = max(f[fail[v]], Len[v]);
        que[++tail] = v;
      } else
        tr[u][i] = tr[fail[u]][i];
    }
  }
}
}  // namespace AC
const int max_len = 10 + 5;
char s[max_len];
const int max_n = 1e3 + 5;
int dp[2][max_n][max_tot];
int main() {
  int n = IO::read_int(), m = IO::read_int();
  for (int i = 1; i <= m; ++i) {
    IO::read_string(s);
    AC::insert(s);
  }
  AC::build();
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    int x = (i - 1) & 1, y = i & 1;
    for (int j = max(i - 9, 0); j <= i; ++j)
      for (int k = 0; k <= tot; ++k) dp[y][j][k] = 0;
    for (int j = max(i - 10, 0); j <= i - 1; ++j)
      for (int k = 0; k <= tot; ++k) {
        if (dp[x][j][k]) {
          for (int l = 0; l < 4; ++l) {
            int Next = tr[k][l];
            if (f[Next] >= i - j) {
              add(dp[y][i][Next], dp[x][j][k]);
            } else {
              add(dp[y][j][Next], dp[x][j][k]);
            }
          }
        }
      }
  }
  int x = n & 1, ans = 0;
  for (int k = 0; k <= tot; ++k) add(ans, dp[x][n][k]);
  IO::write_int(ans);
  IO::write_char('\n');
  IO::flush();
  return 0;
}
