"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>
const int MAXN = 1000, MAXL = 100, MOD = 1e9 + 9, MAXS = (1 << 18) - 1;
int n, m, tmp[MAXL + 5], f[MAXN + 5][MAXL + 5][15];
char str[MAXL + 5];
inline bool add_eq(int& a, const int b) {
  return (a += b) < MOD ? false : (a -= MOD, true);
}
class AcceptedAutomaton {
 private:
  int cnt, fail[MAXL + 5], trans[MAXL + 5][26], ending[MAXL + 5];

 public:
  inline int getcnt() const { return cnt; }
  inline int getcover(const int u) const { return ending[u]; }
  inline int go(const int u, const int c) const { return trans[u][c]; }
  inline void insert(const int* str) {
    int r = 0, len = 0;
    for (int i = 0; ~str[i]; ++i) {
      ++len;
      if (!trans[r][str[i]]) trans[r][str[i]] = ++cnt;
      r = trans[r][str[i]];
    }
    ending[r] = len;
  }
  inline void build() {
    static std ::queue<int> q;
    for (; !q.empty(); q.pop())
      ;
    for (int i = 0; i ^ 26; ++i)
      if (trans[0][i]) q.push(trans[0][i]);
    for (; !q.empty(); q.pop()) {
      int u = q.front();
      ending[u] = ending[u] < ending[fail[u]] ? ending[fail[u]] : ending[u];
      for (int i = 0; i ^ 26; ++i) {
        if (!trans[u][i])
          trans[u][i] = trans[fail[u]][i];
        else
          fail[trans[u][i]] = trans[fail[u]][i], q.push(trans[u][i]);
      }
    }
  }
} ac;
int main() {
  scanf("%d %d", &n, &m);
  int mxl = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%s", str);
    int l = 0;
    for (int j = 0; str[j]; ++j) {
      if (str[j] == 'A') tmp[j] = 0;
      if (str[j] == 'T') tmp[j] = 1;
      if (str[j] == 'C') tmp[j] = 2;
      if (str[j] == 'G') tmp[j] = 3;
      tmp[j + 1] = -1, ++l;
    }
    ac.insert(tmp), mxl = mxl < l ? l : mxl;
  }
  ac.build();
  f[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= ac.getcnt(); ++j) {
      for (int k = 0; k < mxl; ++k) {
        int& cur = f[i][j][k];
        if (!cur) continue;
        for (int c = 0, cover, nxtj, nxtk; c < 4; ++c) {
          cover = ac.getcover(nxtj = ac.go(j, c));
          if (cover >= k + 1)
            nxtk = 0;
          else
            nxtk = k + 1;
          if (nxtk == mxl) continue;
          add_eq(f[i + 1][nxtj][nxtk], cur);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= ac.getcnt(); ++i) add_eq(ans, f[n][i][0]);
  printf("%d\n", ans);
  return 0;
}
