"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 root = 1;
typedef struct T {
  int ch, par, fail, kid[4], next[4], d, len;
  bool end;
} T;
T tree[200];
int tp;
void build(int *x, int len) {
  int cur = root;
  while (len--) {
    if (tree[cur].kid[x[0]] == 0) {
      tp++;
      tree[cur].kid[x[0]] = tp;
      memset(tree + tp, 0, sizeof(tree[0]));
      tree[tp].par = cur;
      tree[tp].ch = x[0];
      tree[tp].d = tree[cur].d + 1;
    }
    cur = tree[cur].kid[x[0]];
    x++;
  }
  tree[cur].end = true;
}
void fail(void) {
  int cur, i, par;
  queue<int> q;
  q.push(root);
  tree[root].par = -1;
  while (q.empty() == false) {
    cur = q.front();
    q.pop();
    for (i = 0; i < 4; i++)
      if (tree[cur].kid[i]) q.push(tree[cur].kid[i]);
    par = tree[cur].par;
    while (1) {
      if (par == -1 || par == root) {
        tree[cur].fail = root;
        break;
      }
      par = tree[par].fail;
      if (tree[par].kid[tree[cur].ch]) {
        tree[cur].fail = tree[par].kid[tree[cur].ch];
        break;
      }
    }
  }
}
void end(void) {
  int cur, par, i;
  queue<int> q;
  q.push(root);
  while (q.empty() == false) {
    cur = q.front();
    q.pop();
    for (i = 0; i < 4; i++)
      if (tree[cur].kid[i]) q.push(tree[cur].kid[i]);
    if (tree[cur].end == true)
      tree[cur].len = tree[cur].d;
    else if (cur != root) {
      int mm = tree[tree[cur].fail].len;
      int nn = mm;
      par = tree[cur].par;
      while (par != root) {
        if (tree[cur].d - tree[par].d <= mm)
          nn = max(nn, tree[par].len + tree[cur].d - tree[par].d);
        par = tree[par].par;
      }
      tree[cur].len = nn;
    }
    if (tree[tree[cur].fail].end == true) tree[cur].end = true;
  }
}
void next(void) {
  int cur, i, j, par;
  for (i = root; i <= tp; i++) {
    for (j = 0; j < 4; j++) {
      if (tree[i].kid[j])
        tree[i].next[j] = tree[i].kid[j];
      else {
        par = i;
        tree[i].next[j] = -1;
        while (par != root) {
          par = tree[par].fail;
          if (tree[par].kid[j]) {
            tree[i].next[j] = tree[par].kid[j];
            break;
          }
        }
      }
    }
  }
}
int trans(char *s, int *x) {
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    switch (s[i]) {
      case 'A':
        x[i] = 0;
        break;
      case 'C':
        x[i] = 1;
        break;
      case 'G':
        x[i] = 2;
        break;
      case 'T':
        x[i] = 3;
        break;
    }
  }
  return len;
}
const long long mod = 1000000009;
long long res[2][200][13];
long long dp(int n) {
  memset(res, 0, sizeof(res));
  res[0][root][0] = 1;
  int i, j, k, q, cur, pre;
  for (i = 1; i <= n; i++) {
    cur = i % 2;
    pre = !cur;
    for (j = root; j <= tp; j++)
      for (k = 0; k < 13; k++) res[cur][j][k] = 0;
    for (j = root; j <= tp; j++) {
      for (k = 0; k < 4; k++) {
        for (q = 0; q < 11; q++) {
          if (tree[j].next[k] != -1) {
            if (tree[tree[j].next[k]].end && tree[tree[j].next[k]].len >= q + 1)
              res[cur][tree[j].next[k]][0] += res[pre][j][q];
            else
              res[cur][tree[j].next[k]][q + 1] += res[pre][j][q];
          }
        }
      }
    }
    for (j = root; j <= tp; j++)
      for (q = 0; q < 11; q++) res[cur][j][q] %= mod;
  }
  long long ans = 0;
  for (i = root; i <= tp; i++) ans += res[cur][i][0];
  return ans % mod;
}
int main() {
  int n, m, i, j;
  char s[100];
  int x[100];
  tp = root;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%s", s);
    build(x, trans(s, x));
  }
  fail();
  end();
  next();
  printf("%lld\n", dp(n));
  return 0;
}
