"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 INF = 1000000000;
const int NMAX = 1000, LENMAX = 10, MOD = 1000000009;
struct FiniteAutomaton {
  static const int ASIZE = 4, NODEMAX = 100, ROOT = 0, NIL = 1;
  struct Node {
    int next[ASIZE], prefix, accept, end, dyn[NMAX + 1][LENMAX];
  } T[NODEMAX + 2];
  int N;
  FiniteAutomaton() : N(2) {
    fill_n(T[ROOT].next, ASIZE, -1);
    T[ROOT].accept = T[ROOT].end = -1;
  }
  int alpha(char c) {
    switch (c) {
      case 'A':
        return 0;
      case 'C':
        return 1;
      case 'G':
        return 2;
      case 'T':
        return 3;
      default:
        return -1;
    }
  };
  void add(const char* str, int n, int label) {
    int ind = ROOT;
    for (int i = 0, _n = (n); i < _n; ++i) {
      int c = alpha(str[i]);
      if (T[ind].next[c] == -1) {
        T[ind].next[c] = N;
        fill_n(T[N].next, ASIZE, -1);
        T[N].accept = T[N].end = -1;
        ++N;
      }
      ind = T[ind].next[c];
    }
    T[ind].end = label;
  }
  void compute() {
    static int Q[NODEMAX + 2], qbeg, qend;
    qbeg = qend = 0;
    fill_n(T[NIL].next, ASIZE, ROOT);
    T[ROOT].prefix = NIL;
    Q[qend++] = ROOT;
    while (qbeg != qend) {
      Node& u = T[Q[qbeg++]];
      for (int c = 0, _n = (ASIZE); c < _n; ++c) {
        if (u.next[c] != -1) {
          Node& v = T[u.next[c]];
          int indw = T[u.prefix].next[c];
          v.prefix = indw;
          v.accept = (T[indw].end != -1 ? indw : T[indw].accept);
          Q[qend++] = u.next[c];
        } else
          u.next[c] = T[u.prefix].next[c];
      }
    }
  }
  int compute_dyn(int uind, int n, int uncovered) {
    Node& u = T[uind];
    int& res = u.dyn[n][uncovered];
    if (res != -1) return res;
    if (n == 0) return res = (uncovered == 0 ? 1 : 0);
    res = 0;
    for (int c = 0, _n = (ASIZE); c < _n; ++c) {
      Node& v = T[u.next[c]];
      int len = 0;
      if (v.end != -1)
        len = v.end;
      else if (v.accept != -1)
        len = T[v.accept].end;
      if (len >= uncovered + 1)
        res += compute_dyn(u.next[c], n - 1, 0);
      else if (uncovered + 1 < LENMAX)
        res += compute_dyn(u.next[c], n - 1, uncovered + 1);
      if (res >= MOD) res -= MOD;
    }
    return res;
  }
} A;
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0, _n = (M); i < _n; ++i) {
    static char buf[LENMAX + 1];
    scanf("%s", buf);
    int len = strlen(buf);
    A.add(buf, len, len);
  }
  A.compute();
  for (int i = 0, _n = (A.N); i < _n; ++i)
    for (int j = (0), _n = (N); j <= _n; ++j) fill_n(A.T[i].dyn[j], LENMAX, -1);
  printf("%d\n", A.compute_dyn(FiniteAutomaton::ROOT, N, 0));
}
