"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;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;
const int N = 1000 + 13;
const int V = 100 + 13;
const string ALP = "ACGT";
struct node {
  int next[4], go[4];
  int p, link, len;
  bool leaf;
  char pch;
  int maxPref;
  node(int p, char c)
      : p(p), pch(c), link(-1), len(-1), leaf(false), maxPref(-1) {
    memset(next, -1, sizeof(next));
    memset(go, -1, sizeof(go));
  }
  node(int p = -1, int link = -1, int len = -1, bool leaf = false, char pch = 0,
       int maxPref = -1)
      : p(p), link(link), len(len), leaf(leaf), pch(pch), maxPref(maxPref) {
    memset(next, -1, sizeof(next));
    memset(go, -1, sizeof(go));
  }
};
int n, m;
node t[V];
int szt;
const int MOD = 1000 * 1000 * 1000 + 9;
void add(string s) {
  int v = 0;
  for (int i = 0; i < int(int((s).size())); i++) {
    int c = ALP.find(s[i]);
    assert(c != string::npos);
    if (t[v].next[c] == -1) {
      t[v].next[c] = szt;
      t[szt++] = node(v, s[i]);
    }
    v = t[v].next[c];
  }
  t[v].leaf = true;
  t[v].len = int((s).size());
  t[v].maxPref = int((s).size());
}
int link(int);
int down(int v, char ch) {
  int c = ALP.find(ch);
  if (t[v].go[c] == -1) {
    if (t[v].next[c] != -1)
      t[v].go[c] = t[v].next[c];
    else if (v == 0)
      t[v].go[c] = 0;
    else
      t[v].go[c] = down(link(v), ch);
  }
  return t[v].go[c];
}
int link(int v) {
  if (t[v].link == -1) {
    if (t[v].p == 0)
      t[v].link = 0;
    else
      t[v].link = down(link(t[v].p), t[v].pch);
  }
  return t[v].link;
}
int getMaxPref(int v) {
  if (t[v].maxPref == -1) t[v].maxPref = max(0, getMaxPref(link(v)));
  return t[v].maxPref;
}
int d[N][V][13];
int solve(int pos, int v, int notcov) {
  if (notcov > 10) return 0;
  int& res = d[pos][v][notcov];
  if (res != -1) return res;
  if (pos == n) return res = (notcov == 0);
  res = 0;
  for (int i = 0; i < int(4); i++) {
    int nv = down(v, ALP[i]);
    if (nv == 0) continue;
    int nnotcov = notcov + 1;
    if (t[nv].maxPref >= nnotcov) nnotcov = 0;
    res += solve(pos + 1, nv, nnotcov);
    while (res >= MOD) res -= MOD;
  }
  return res;
}
int main() {
  cin >> n >> m;
  t[szt++] = node(0, 0, 0, true, 0, 0);
  for (int i = 0; i < int(m); i++) {
    string s;
    cin >> s;
    add(s);
  }
  for (int i = 0; i < int(szt); i++) t[i].link = link(i);
  for (int i = 0; i < int(szt); i++) t[i].maxPref = getMaxPref(i);
  memset(d, -1, sizeof(d));
  cout << solve(0, 0, 0) << endl;
  return 0;
}
