"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;
template <class _T>
inline _T sqr(const _T &x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T &a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
const int MOD = 1000000009;
const int pp = 5200007;
int n, m, k, kk;
string s[32];
int p[32][32];
int b[1024000][12];
signed long long hh[pp];
int gg[pp];
vector<int> q[1012][12];
int d[1024000];
inline void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void calc_pref(const char *s, int *p, int n) {
  int q = -1;
  p[0] = -1;
  for (int i = (1); i <= (int)(n - 1); i++) {
    while (q != -1 && s[i] != s[q + 1]) q = p[q];
    if (s[i] == s[q + 1]) q++;
    p[i] = q;
  }
}
signed long long calc_hash(int *a, int n) {
  signed long long z = 170;
  for (int i = 0; i < (int)(n); i++) {
    z = z * 23917 + (a[i] + 170);
  }
  return z;
}
void hinsert(signed long long x, int k) {
  int j = x % pp;
  if (j < 0) j += pp;
  while (hh[j] != -1) {
    if (hh[j] == x) return;
    j += 1997;
    if (j >= pp) j -= pp;
  }
  hh[j] = x;
  gg[j] = k;
}
int hfind(signed long long x) {
  int j = x % pp;
  if (j < 0) j += pp;
  while (hh[j] != -1) {
    if (hh[j] == x) return gg[j];
    j += 1997;
    if (j >= pp) j -= pp;
  }
  return -1;
}
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  memset(hh, 0xff, sizeof(hh));
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> s[i];
  }
  sort(s, s + m);
  m = unique(s, s + m) - s;
  for (int i = 0; i < (int)(m); i++) {
    calc_pref(s[i].c_str(), p[i], s[i].size());
  }
  memset((d), 0, sizeof(d));
  kk = 0;
  int tmp[12];
  for (int i = 0; i < (int)(m); i++) {
    tmp[i] = -1;
  }
  tmp[m] = 0;
  tmp[m + 1] = 0;
  signed long long h = calc_hash(tmp, m + 2);
  d[kk] = 1;
  memcpy(b[kk], tmp, (m + 2) * sizeof(*tmp));
  q[0][0].push_back(kk);
  hinsert(h, kk++);
  int y[12];
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    for (int l = 0; l < (int)(20); l++) {
      for (int q1 = 0; q1 < (int)(q[i][l].size()); q1++) {
        int *x = b[q[i][l][q1]];
        for (int c = 0; c < (int)(26); c++) {
          char cc = c + 'A';
          int nl = l + 1;
          bool bb = false;
          for (int t = 0; t < (int)(m); t++) {
            int q = x[t];
            while (q != -1 && s[t][q + 1] != cc) q = p[t][q];
            if (s[t][q + 1] == cc) q++;
            if (q == (int)s[t].size() - 1) {
              q = p[t][q];
              if ((int)s[t].size() >= l + 1) nl = 0, bb = true;
            }
            y[t] = q;
          }
          for (int t = 0; t < (int)(m); t++) {
            if (y[t] + 1 >= l + 1) {
              bb = true;
              break;
            }
          }
          if (bb) {
            y[m] = i + 1;
            y[m + 1] = nl;
            signed long long h = calc_hash(y, m + 2);
            int z = hfind(h);
            if (z == -1) {
              z = kk;
              d[kk] = 0;
              memcpy(b[kk], y, (m + 2) * sizeof(*y));
              q[i + 1][nl].push_back(kk);
              hinsert(h, kk++);
            }
            add(d[z], d[q[i][l][q1]]);
            if (i + 1 == n && !nl) {
              add(ans, d[q[i][l][q1]]);
            }
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
