Recently a top secret mission to Mars has taken place. As a result, scientists managed to obtain some information about the Martian DNA. Now we know that any Martian DNA contains at most m different nucleotides, numbered from 1 to m. Special characteristics of the Martian DNA prevent some nucleotide pairs from following consecutively in this chain. For example, if the nucleotide 1 and nucleotide 2 can not follow consecutively in the Martian DNA, then the chain of nucleotides [1, 2] is not a valid chain of Martian DNA, but the chain of nucleotides [2, 1] can be a valid chain (if there is no corresponding restriction). The number of nucleotide pairs that can't follow in the DNA chain consecutively, is k. 

The needs of gene research required information about the quantity of correct n-long chains of the Martian DNA. Your task is to write a program that will calculate this value.

Input

The first line contains three space-separated integers n, m, k (1 ≤ n ≤ 1015, 1 ≤ m ≤ 52, 0 ≤ k ≤ m2).

Next k lines contain two characters each, without a space between them, representing a forbidden nucleotide pair. The first character represents the first nucleotide in the forbidden pair, the second character represents the second nucleotide.

The nucleotides with assigned numbers from 1 to 26 are represented by English alphabet letters from "a" to "z" (1 is an "a", 2 is a "b", ..., 26 is a "z"). Nucleotides with assigned numbers from 27 to 52 are represented by English alphabet letters from "A" to "Z" (27 is an "A", 28 is a "B", ..., 52 is a "Z").

It is guaranteed that each forbidden pair occurs at most once in the input. It is guaranteed that nucleotide's numbers in all forbidden pairs cannot be more than m. Note that order is important in nucleotide pairs.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Output

Print a single integer — the sought number modulo 1000000007 (109 + 7).

Examples

Input

3 3 2
ab
ba


Output

17


Input

3 3 0


Output

27


Input

2 1 1
aa


Output

0

Note

In the second test case all possible three-nucleotide DNAs are permitted. Each nucleotide can take one of three values, thus in total there are 27 distinct three nucleotide DNAs.

In the third test sample we cannot make any DNA of two nucleotides — the only possible nucleotide "a" cannot occur two times consecutively.
import java.io.*;
import java.util.*;

public class C {

	static int mod = 1000000007;

	static int[][] matMul(int[][] A, int[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		int[][] C = new int[p][r];
		for (int i = 0; i < p; ++i)
			for (int j = 0; j < r; ++j)
				for (int k = 0; k < q; ++k) {
					C[i][j] += (A[i][k] * 1l * B[k][j]) % mod;
					C[i][j] %= mod;
				}
		return C;
	}

	/*
	 * 4. Square Matrix Exponentiation
	 */
	static int[][] matPow(int[][] base, long p) {
		int n = base.length;
		int[][] ans = new int[n][n];
		for (int i = 0; i < n; i++)
			ans[i][i] = 1;
		while (p != 0) {
			if ((p & 1) == 1)
				ans = matMul(ans, base, n, n, n);
			base = matMul(base, base, n, n, n);
			p >>= 1;
		}

		return ans;
	}

	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		long n = sc.nextLong();
		int m = sc.nextInt();
		int k = sc.nextInt();
		
		int mul[][]=new int[m][m];
		
		HashSet<Integer> []a=new HashSet[m];
		for (int i = 0; i < a.length; i++) {
			a[i]=new HashSet<>();
		}
		for (int i = 0; i < k; i++) {
			char c[]=sc.next().toCharArray();
			int u=c[0]-'A'+26;
			int v=c[1]-'A'+26;
			if(c[0]<='z'&& c[0]>='a')
				u=c[0]-'a';
			if(c[1]<='z'&& c[1]>='a')
				v=c[1]-'a';
			
			a[v].add(u);
		}
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a.length; j++) {
				if(!a[i].contains(j))
					mul[i][j]=1;
			}
		}
//		for (int i = 0; i < a.length; i++) {
//			System.out.println(Arrays.toString(mul[i]));
//		}
		int x[][]=new int[m][1];
		for (int i = 0; i < x.length; i++) {
			x[i][0]++;
		}
		
		int ans[][]=matMul(matPow(mul, n-1), x, m, m, 1);
		long sum=0;
		for (int i = 0; i < x.length; i++) {
			sum+=ans[i][0];
			sum%=mod;
		}
		 pw.print(sum);
		pw.flush();
	}

	///////////////////////////////////////////////////////////////////////////////////////////

	static class tri {
		int x, y, z;

		public tri(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

	}

	static class pair implements Comparable<pair> {
		int x, y;
		boolean w, l;
		PriorityQueue<Long> pq;

		public pair(boolean a, boolean b) {
			w = a;
			l = b;
		}

		pair(int s, int d) {
			x = s;
			y = d;
		}

		@Override
		public int compareTo(pair p) {
			return y - p.y;
		}

		@Override
		public String toString() {
			return x + " " + y;

		}

	}

	static long mod(long ans, int mod) {
		return (ans % mod + mod) % mod;
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static int log(long k, int base) {
		int ans = 0;
		while (k + 1 > base) {
			ans++;
			k /= base;
		}
		return ans;
	}

	static long pow(long b, long e) {
		long ans = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				ans = ((ans * 1l * b));
			e >>= 1;
			{

			}
			b = ((b * 1l * b));
		}
		return ans;
	}

	static long powmod(long r, long e, int mod) {
		long ans = 1;
		r %= mod;
		while (e > 0) {
			if ((e & 1) == 1)
				ans = (int) ((ans * 1l * r) % mod);
			e >>= 1;
			r = (int) ((r * 1l * r) % mod);
		}
		return ans;
	}

	static int ceil(int a, int b) {
		int ans = a / b;
		return a % b == 0 ? ans : ans + 1;
	}

	static long ceil(long a, long b) {
		long ans = a / b;
		return a % b == 0 ? ans : ans + 1;
	}

	static HashMap<Integer, Integer> compress(int a[]) {
		TreeSet<Integer> ts = new TreeSet<>();
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : a)
			ts.add(x);
		for (int x : ts) {
			hm.put(x, hm.size() + 1);
		}
		return hm;
	}

	// Returns nCr % p
	static int C[];

	static int nCrModp(int n, int r, int p) {
		if (r > n - r)
			r = n - r;
		if (C[r] != 0)
			return C[r];
		// The array C is going to store last
		// row of pascal triangle at the end.
		// And last entry of last row is nCr

		C[0] = 1; // Top row of Pascal Triangle

		// One by constructs remaining rows of Pascal
		// Triangle from top to bottom
		for (int i = 1; i <= n; i++) {

			// Fill entries of current row using previous
			// row values
			for (int j = Math.min(i, r); j > 0; j--)

				// nCj = (n-1)Cj + (n-1)C(j-1);
				C[j] = (C[j] + C[j - 1]) % p;
		}
		return C[r];
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public int[] intArr(int n) throws IOException {
			int a[] = new int[n];
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public long[] longArr(int n) throws IOException {
			long a[] = new long[n];
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

	public static void shuffle(int[] times2) {
		int n = times2.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = times2[i];
			times2[i] = times2[r];
			times2[r] = tmp;
		}
	}

}