"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;
const int MAXN = 1005;
const int MAXS = 15;
const int P = 1e9 + 9;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
namespace ACAutomaton {
const int MAXP = 105;
const int MAXC = 4;
int root, size;
bool key[MAXP];
int child[MAXP][MAXC];
int depth[MAXP], fail[MAXN], last[MAXN];
void init() { root = size = 0; }
int index(char x) {
  if (x == 'A') return 0;
  if (x == 'C') return 1;
  if (x == 'G') return 2;
  return 3;
}
void insert(char *s) {
  int len = strlen(s + 1), now = root;
  for (int i = 1; i <= len; i++) {
    int tmp = index(s[i]);
    if (child[now][tmp] == 0) {
      child[now][tmp] = ++size;
      depth[size] = depth[now] + 1;
    }
    now = child[now][tmp];
  }
  key[now] = true;
}
void build() {
  static int q[MAXP];
  int l = 0, r = -1;
  for (int i = 0; i < MAXC; i++)
    if (child[root][i]) {
      q[++r] = child[root][i];
      fail[child[root][i]] = root;
      last[child[root][i]] = root;
    }
  while (l <= r) {
    int tmp = q[l++];
    for (int i = 0; i < MAXC; i++)
      if (child[tmp][i]) {
        q[++r] = child[tmp][i];
        fail[child[tmp][i]] = child[fail[tmp]][i];
      } else
        child[tmp][i] = child[fail[tmp]][i];
    last[tmp] = key[fail[tmp]] ? fail[tmp] : last[fail[tmp]];
  }
}
void update(int &x, int y) { x = (x + y) % P; }
void dp(int n) {
  static int dp[MAXN][MAXP][MAXS];
  dp[0][root][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= size; j++)
      for (int k = 0; k < MAXS; k++) {
        int tmp = dp[i][j][k];
        if (tmp == 0) continue;
        for (int c = 0; c < MAXC; c++) {
          int dest = child[j][c];
          if (depth[dest] < k + 1) continue;
          int tk = k + 1;
          if (key[dest])
            tk = 0;
          else if (depth[last[dest]] >= tk)
            tk = 0;
          update(dp[i + 1][dest][tk], tmp);
        }
      }
  int ans = 0;
  for (int i = 0; i <= size; i++) update(ans, dp[n][i][0]);
  writeln(ans);
}
};  // namespace ACAutomaton
int n, m;
char s[MAXS];
int main() {
  read(n), read(m);
  ACAutomaton::init();
  for (int i = 1; i <= m; i++) {
    scanf("\n%s", s + 1);
    ACAutomaton::insert(s);
  }
  ACAutomaton::build();
  ACAutomaton::dp(n);
  return 0;
}
