"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.util.*;

public class C {
	private static Scanner in;
	
	class State {
		String s;
		int c;
		
		public State(String s, int c) {
			this.s = s;
			this.c = c;
		}

		@Override
		public int hashCode() {
			return 13 * s.hashCode() + c;
		}
		
		@Override
		public boolean equals(Object obj) {
			State that = (State) obj;
			return s.equals(that.s) && c == that.c;
		}
		
		boolean isTerminal() {
			return s.length() == c;
		}
		
		State step(char n) {
			int c1 = c;
			String ss = s + n;
			for (;;) {
				int cbest = c1;
				for (String d : dna) {
					for (int i = 0; i <= c1; i++) {
						if (ss.substring(i).startsWith(d)) {
							cbest = Math.max(cbest, i + d.length());
						}
					}
				}
				if (cbest == c1) {
					break;
				}
				c1 = cbest;
			}
			loop:
			for (;;) {
				for (String d : dna) {
					if (d.startsWith(ss)) {
						break loop;
					}
				}
				ss = ss.substring(1);
				c1--;
			}
			if (c1 < 0) {
				return null;
			}
			return new State(ss, c1);
		}
	}

	String[] dna;
	HashMap<State, Integer> map = new HashMap<State, Integer>();
	int[][] nxt = new int[2000][4];
	boolean[] trm = new boolean[2000];
	char[] ns = new char[]{'A', 'C', 'G', 'T'};
	
	public void run() {
		int n = in.nextInt();
		int m = in.nextInt();
		dna = new String[m];
		for (int i = 0; i < m; i++) {
			dna[i] = in.next();
		}
		State s0 = new State("", 0);
		dfs(s0);
		int k = map.size();
		int[][] a = new int[n + 1][k];
		a[0][0] = 1;
		for (int len = 0; len < n; len++) {
			for (int s = 0; s < k; s++) {
				int aa = a[len][s];
				if (aa == 0) {
					continue;
				}
				for (int i = 0; i < 4; i++) {
					int t = nxt[s][i];
					if (t < 0) {
						continue;
					}
					a[len + 1][t] = add(a[len + 1][t], aa);
				}
			}
		}
		int ans = 0;
		for (int s = 0; s < k; s++) {
			if (trm[s]) {
				ans = add(ans, a[n][s]);
			}
		}
		System.out.println(ans);
	}

	final int MOD = 1000000009;
	
	private int add(int x, int y) {
		x += y;
		if (x >= MOD) {
			x -= MOD;
		}
		return x;
	}

	private void dfs(State st) {
		if (map.containsKey(st)) {
			return;
		}
		int v = map.size();
		map.put(st, v);
		trm[v] = st.isTerminal();
		for (int i = 0; i < 4; i++) {
			State u = st.step(ns[i]);
			if (u == null) {
				nxt[v][i] = -1;
				continue;
			}
			dfs(u);
			nxt[v][i] = map.get(u);
		}
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		in = new Scanner(System.in);
		new C().run();
		in.close();
	}
}
