"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 = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;
const int MOD = INF + 9;
const int MAXN = 1100;
struct vertex {
  int next[4], go[4], here, dp, link, prec, prev;
  vertex() {
    memset(next, 255, sizeof next);
    memset(go, 255, sizeof go);
    dp = link = prev = prec = -1;
    here = 0;
  }
};
int n, m, size = 1, d[MAXN][110][50];
string a[15];
vertex tree[MAXN];
inline int get(char c) {
  if (c == 'A') return 0;
  if (c == 'G') return 1;
  if (c == 'T') return 2;
  if (c == 'C') return 3;
  throw;
}
void add(string s) {
  int v = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    int c = get(s[i]);
    if (tree[v].next[c] == -1) {
      tree[v].next[c] = size;
      tree[size].prev = v;
      tree[size].prec = c;
      size++;
    }
    v = tree[v].next[c];
  }
  tree[v].here = (int)s.size();
}
int calcLink(int v);
int calcGo(int v, int c) {
  if (tree[v].go[c] != -1) return tree[v].go[c];
  if (tree[v].next[c] != -1) return tree[v].go[c] = tree[v].next[c];
  if (v == 0) return tree[v].go[c] = 0;
  return tree[v].go[c] = calcGo(calcLink(v), c);
}
int calcLink(int v) {
  if (tree[v].link != -1) return tree[v].link;
  if (tree[v].prev == 0 || v == 0) return tree[v].link = 0;
  if (tree[v].prev == 0) return tree[v].link = 0;
  return tree[v].link = calcGo(calcLink(tree[v].prev), tree[v].prec);
}
int calcDP(int v) {
  if (v == 0) return 0;
  int &ans = tree[v].dp;
  if (ans != -1) return ans;
  ans = max(tree[v].here, calcDP(calcLink(v)));
  return ans;
}
bool catchPos(int p, int len) { return p < len; }
int solve(int len, int v, int p) {
  if (p > 20) return 0;
  if (len == n) {
    if (p == 0) return 1;
    return 0;
  }
  int &ans = d[len][v][p];
  if (ans != -1) return ans;
  ans = 0;
  for (int c = 0; c < (int)(4); c++) {
    int nlen = len + 1;
    int nv = calcGo(v, c);
    int np = (catchPos(p, calcDP(nv))) ? (0) : (p + 1);
    ans = (ans + solve(nlen, nv, np)) % MOD;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i];
    add(a[i]);
  }
  memset(d, 255, sizeof d);
  cout << solve(0, 0, 0) << endl;
  return 0;
}
