"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 mod = 1e9 + 9;
inline int get_idx(char ch) {
  if (ch == 'A') return 0;
  if (ch == 'C') return 1;
  if (ch == 'G') return 2;
  return 3;
}
int node_num;
struct Node {
  Node *next_ptr[4], *fail;
  int max_full, id;
  Node() {
    for (int i = 0; i < 4; i++) next_ptr[i] = nullptr;
    fail = nullptr;
    max_full = 0;
    id = ++node_num;
  }
}* root = new Node();
void insert(string str) {
  Node* node = root;
  for (int i = 0; i < (int)str.size(); i++) {
    int idx = get_idx(str[i]);
    if (node->next_ptr[idx] == nullptr) node->next_ptr[idx] = new Node();
    node = node->next_ptr[idx];
  }
  node->max_full = (int)str.size();
}
Node* get_next(Node* node, int idx) {
  while (node->next_ptr[idx] == nullptr) node = node->fail;
  return node->next_ptr[idx];
}
void bfs() {
  queue<Node*> q;
  for (int i = 0; i < 4; i++) {
    if (root->next_ptr[i] == nullptr) {
      root->next_ptr[i] = root;
    } else {
      root->next_ptr[i]->fail = root;
      q.push(root->next_ptr[i]);
    }
  }
  while (!q.empty()) {
    Node* node = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      if (node->next_ptr[i] != nullptr) {
        node->next_ptr[i]->fail = get_next(node->fail, i);
        node->next_ptr[i]->max_full =
            max(node->next_ptr[i]->max_full, node->next_ptr[i]->fail->max_full);
        q.push(node->next_ptr[i]);
      }
    }
  }
}
int dp[1010][110][15];
bool vis[1010][110][15];
struct Status {
  int len, k;
  Node* node;
  Status(int _len = 0, int _k = 0, Node* _node = nullptr)
      : len(_len), k(_k), node(_node) {}
};
char str[15];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%s", str);
    insert(string(str));
  }
  bfs();
  dp[0][1][0] = 1;
  vis[0][1][0] = true;
  queue<Status> q;
  q.push(Status(0, 0, root));
  while (!q.empty()) {
    Node* cur = q.front().node;
    int len = q.front().len;
    int k = q.front().k;
    q.pop();
    if (len == n) continue;
    for (int i = 0; i < 4; i++) {
      Node* nxt = get_next(cur, i);
      if (nxt->max_full > k) {
        dp[len + 1][nxt->id][0] =
            (dp[len + 1][nxt->id][0] + dp[len][cur->id][k]) % mod;
        if (!vis[len + 1][nxt->id][0]) {
          vis[len + 1][nxt->id][0] = true;
          q.push(Status(len + 1, 0, nxt));
        }
      } else {
        if (k >= 9) continue;
        dp[len + 1][nxt->id][k + 1] =
            (dp[len + 1][nxt->id][k + 1] + dp[len][cur->id][k]) % mod;
        if (!vis[len + 1][nxt->id][k + 1]) {
          vis[len + 1][nxt->id][k + 1] = true;
          q.push(Status(len + 1, k + 1, nxt));
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= node_num; i++) ans = (ans + dp[n][i][0]) % mod;
  printf("%d\n", ans);
  return 0;
}
