"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>
import java.io.*;
import java.util.*;
 
public class Main  {
 
    private static final InputStream inputStream = System.in;
    private static final Scanner in = new Scanner(inputStream);
 
    private static final int M = 1000000009;
    private static final String str = "ACGT";
 
    public static void main(String[] args) {
        solve();
    }
 
    private static void solve() {
        int n = scanInt();
        int m = scanInt();
        Set<String> all = new HashSet<>();
        Set<String> finish = new HashSet<>();
        all.add("");
        int maxSize = 1;
        for (int i = 0; i < m; i++) {
            String string = next();
            int len = string.length();
            maxSize = Math.max(maxSize, len);
            finish.add(string);
            for (int j = 0; j < len; j++) {
                all.add(string.substring(0, j + 1));
            }
        }
        Map<String, Integer> map = new HashMap<>();
        int last = 0;
        for (String st : all) {
            map.put(st, last++);
        }
        int[] isFinish = new int[last];
        int[][] next = new int[last][4];
        for (String s : all) {
            for (String t : finish) {
                if (s.endsWith(t)) {
                    isFinish[map.get(s)] = Math.max(isFinish[map.get(s)], t.length());
                }
            }
        }
        for (String s : all) {
            int start = map.get(s);
            for (int ch = 0; ch < 4; ch++) {
                String t = s + str.charAt(ch);
                while (!all.contains(t)) {
                    t = t.substring(1);
                }
                next[start][ch] = map.get(t);
            }
        }
        int[][] counts = new int[last][maxSize];
        counts[map.get("")][0] = 1;
        for (int i = 0; i < n; i++) {
            counts = oneStep(counts, maxSize, last, isFinish, next);
        }
        int result = 0;
        for (int i = 0; i < last; i++) {
            result += counts[i][0];
            if (result >= M) {
                result -= M;
            }
        }
        System.out.println(result);
    }
 
    private static int[][] oneStep(int[][] counts, int maxSize, int last, int[] finish, int[][] next) {
        int[][] newCounts = new int[last][maxSize];
        for (int i = 0; i < last; i++) {
            for (int j = 0; j < maxSize; j++) {
                for (int ch = 0; ch < 4; ch++) {
                    int newState = next[i][ch];
                    int newNeed = j + 1;
                    if (newNeed <= finish[newState]) {
                        newNeed = 0;
                    }
                    if (newNeed >= maxSize) {
                        continue;
                    }
                    newCounts[newState][newNeed] += counts[i][j];
                    if (newCounts[newState][newNeed] >= M) {
                        newCounts[newState][newNeed] -= M;
                    }
                }
            }
        }
        return newCounts;
    }
 
    private static int scanInt() {
        return Integer.parseInt(in.next());
    }
 
    private static long scanLong() {
        return Long.parseLong(in.next());
    }
 
    private static String next() {
        return in.next();
    }
 
    private static int nextInt() {
        return in.nextInt();
    }
 
    private static int[] nextArrayInt(int len) {
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = scanInt();
        }
        return array;
    }
}