"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;
inline long long read() {
  long long Hashimoto = 0;
  bool Kanna = 1;
  char I_Love = getchar();
  while (I_Love < '0' || I_Love > '9') {
    if (I_Love == '-') Kanna = 0;
    I_Love = getchar();
  }
  while (I_Love >= '0' && I_Love <= '9') {
    Hashimoto = Hashimoto * 10 + I_Love - '0';
    I_Love = getchar();
  }
  return (Kanna ? Hashimoto : -Hashimoto);
}
template <typename T1, typename T2>
inline void Umax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void Umin(T1 &a, T2 b) {
  if (a > b) a = b;
}
struct node {
  int next[4];
  int go[4];
  int link, end, dp_end, f, fc;
  node() {
    memset(next, -1, sizeof(next));
    memset(go, -1, sizeof(go));
    link = end = dp_end = -1;
  }
} v[222];
int vsz = 1;
void add_string(string s) {
  int root = 0;
  for (int i = 0; i < (s.size()); ++i) {
    if (v[root].next[s[i]] == -1) {
      v[root].next[s[i]] = vsz;
      v[vsz].f = root;
      v[vsz].fc = s[i];
      vsz++;
    }
    root = v[root].next[s[i]];
  }
  v[root].end = s.size();
}
int get_link(int vt);
int go(int vt, int c) {
  if (v[vt].go[c] != -1) {
    return v[vt].go[c];
  }
  if (v[vt].next[c] != -1) {
    return v[vt].go[c] = v[vt].next[c];
  }
  return v[vt].go[c] = vt == 0 ? 0 : go(get_link(vt), c);
}
int get_link(int vt) {
  if (v[vt].link != -1) return v[vt].link;
  return v[vt].link =
             (vt == 0 || v[vt].f == 0 ? 0 : go(get_link(v[vt].f), v[vt].fc));
}
int get_end(int vt) {
  int &ret = v[vt].dp_end;
  if (ret != -1) return ret;
  ret = v[vt].end;
  if (vt != get_link(vt)) Umax(ret, get_end(get_link(vt)));
  return ret;
}
int n, m;
int dp[1111][13][222];
int dfs(int pos, int lst, int ver) {
  int need = pos - lst;
  if (need > 11) return 0;
  int &my = dp[pos][pos - lst][ver];
  if (my != -1) return my;
  if (need && get_end(ver) >= need) {
    return my = dfs(pos, pos, ver);
  }
  if (pos == n) {
    if (lst == n)
      return my = 1;
    else
      return my = 0;
  }
  my = 0;
  for (int k = 0; k < (4); ++k) {
    my += dfs(pos + 1, lst, go(ver, k));
    if (my >= (1000000009)) my -= (1000000009);
  }
  return my;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    string s;
    cin >> s;
    string FA = "ACGT";
    for (int i = 0; i < (s.size()); ++i) s[i] = FA.find(s[i]);
    add_string(s);
  }
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, 0, 0) << endl;
  return 0;
}
