"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;
struct AC {
  static const int K = 1 << 8;
  struct node {
    int nxt[K], go[K], link, leaf, par, len = 0;
    char pch;
    node(int par = -1, char pch = '$') : par(par), pch(pch) {
      fill(begin(nxt), end(nxt), -1);
      fill(begin(go), end(go), -1);
      leaf = false;
      link = -1;
    }
  };
  vector<node> tree;
  AC() { tree.resize(1); }
  int add(string str) {
    int ptr = 0, l = 0;
    for (auto ch : str) {
      if (tree[ptr].nxt[ch] == -1) {
        tree[ptr].nxt[ch] = tree.size();
        tree.push_back(node(ptr, ch));
      }
      ptr = tree[ptr].nxt[ch];
      tree[ptr].len = ++l;
    }
    tree[ptr].leaf = true;
    return ptr;
  }
  int get_link(int v) {
    if (tree[v].link == -1) {
      if (v == 0 || tree[v].par == 0) {
        tree[v].link = 0;
      } else {
        tree[v].link = go(get_link(tree[v].par), tree[v].pch);
      }
    }
    return tree[v].link;
  }
  int go(int v, char ch) {
    if (tree[v].go[ch] == -1) {
      if (tree[v].nxt[ch] != -1) {
        tree[v].go[ch] = tree[v].nxt[ch];
      } else {
        tree[v].go[ch] = (v == 0) ? 0 : go(get_link(v), ch);
      }
    }
    return tree[v].go[ch];
  }
} ac;
const int N = 111, mod = 1e9 + 9;
int n, m, leafleaf[N], lenlen[N], dp[1111][111][111];
vector<int> adj[N];
string ss;
int f(int len, int v, int lst_end) {
  if (len - lst_end > 10) {
    return 0;
  }
  int nxt_end = lst_end;
  if (leafleaf[v] && (len - lenlen[v] <= lst_end)) {
    nxt_end = len;
  }
  if (len == n) {
    return nxt_end == len;
  }
  if (~dp[len][v][len - lst_end]) {
    return dp[len][v][len - lst_end];
  }
  int res = 0;
  char s[] = {'A', 'T', 'G', 'C'};
  for (int i = 0; i < 4; i++)
    if (ac.go(v, s[i]) > 0) {
      res += f(len + 1, ac.go(v, s[i]), nxt_end);
      res %= mod;
    }
  return dp[len][v][len - lst_end] = res;
}
void dfs(int v, int p) {
  if (ac.tree[v].leaf) {
    leafleaf[v] = 1;
    lenlen[v] = ac.tree[v].len;
  } else if (leafleaf[p]) {
    leafleaf[v] = 1;
    lenlen[v] = lenlen[p];
  }
  for (int u : adj[v]) {
    dfs(u, v);
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    string str;
    cin >> str;
    ac.add(str);
  }
  for (int i = 1; i < ac.tree.size(); ++i) {
    adj[ac.get_link(i)].push_back(i);
  }
  dfs(0, 0);
  memset(dp, -1, sizeof dp);
  cout << f(0, 0, 0) << endl;
}
