"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>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = ((1 << 31) - 1);
const long long LLINF = (((1LL << 63) - 1LL));
const double eps = 1e-9;
const double PI = 3.14159265358979323846;
const int ALPHA_SIZE = 4;
int len;
const int MOD = 1e9 + 9;
int dp[1001][4002][10 + 2];
int add(int x, int y) {
  if (x + y >= MOD) return x + y - MOD;
  return x + y;
}
bool endsWith(string &word, string &suff) {
  return (word.size() >= suff.size() &&
          word.substr(word.size() - suff.size(), suff.size()) == suff);
}
string f(string a) {
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == 'A')
      a[i] = 'A';
    else if (a[i] == 'G')
      a[i] = 'B';
    else if (a[i] == 'C')
      a[i] = 'C';
    else if (a[i] == 'T')
      a[i] = 'D';
  }
  return a;
}
int main() {
  int n;
  cin >> len >> n;
  vector<string> words(n);
  for (int i = 0; i < n; ++i) {
    cin >> words[i];
    words[i] = f(words[i]);
  }
  vector<string> prefixes;
  prefixes.push_back("");
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= words[i].size(); ++j)
      prefixes.push_back(words[i].substr(0, j));
  }
  sort((prefixes).begin(), (prefixes).end());
  prefixes.erase(unique((prefixes).begin(), (prefixes).end()), prefixes.end());
  vector<int> prefix_cover(prefixes.size());
  for (int i = 0; i < prefixes.size(); ++i) {
    for (int j = 0; j < words.size(); ++j) {
      if (prefixes[i].size() >= words[j].size() &&
          words[j] == prefixes[i].substr(prefixes[i].size() - words[j].size(),
                                         words[j].size()))
        prefix_cover[i] = max(prefix_cover[i], int(words[j].size()));
    }
  }
  vector<vector<int> > to(prefixes.size(), vector<int>(ALPHA_SIZE, -1));
  for (int i = 0; i < prefixes.size(); ++i) {
    for (char ch = 'A'; ch < 'A' + ALPHA_SIZE; ++ch) {
      string t = prefixes[i] + ch;
      for (int j = 0; j < prefixes.size(); ++j) {
        if (endsWith(t, prefixes[j]) &&
            (to[i][ch - 'A'] == -1 ||
             prefixes[to[i][ch - 'A']].size() < prefixes[j].size())) {
          to[i][ch - 'A'] = j;
        }
      }
    }
  }
  for (int p = 0; p < prefixes.size(); ++p) {
    dp[len][p][0] = 1;
  }
  for (int pos = len - 1; pos >= 0; --pos) {
    for (int prefix_id = 0; prefix_id < prefixes.size(); ++prefix_id) {
      for (int need_to_cover = 0; need_to_cover <= prefixes[prefix_id].size();
           ++need_to_cover) {
        int cnt = 0;
        for (int c = 0; c < ALPHA_SIZE; ++c) {
          int move_to = to[prefix_id][c];
          if (move_to == -1) continue;
          int will_cover = prefix_cover[move_to];
          if (need_to_cover + 1 <= will_cover)
            cnt = add(cnt, dp[pos + 1][move_to][0]);
          else if (need_to_cover + 1 <= prefixes[move_to].size())
            cnt = add(cnt, dp[pos + 1][move_to][need_to_cover + 1]);
        }
        dp[pos][prefix_id][need_to_cover] = cnt;
      }
    }
  }
  cout << dp[0][0][0] << "\n";
  return 0;
}
