#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long a[52][52], b[52][52], sz;
int cal(char c) {
  if (c >= 'a' && c <= 'z')
    return c - 'a';
  else
    return c - 'A' + 26;
}
void mult(long long a[][52], long long b[][52]) {
  long long tmp[52][52] = {0};
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++)
      for (int r = 0; r < sz; r++)
        tmp[i][j] = (tmp[i][j] + a[i][r] * b[r][j]) % mod;
  memcpy(a, tmp, sizeof(tmp));
}
int main() {
  long long n;
  int k;
  char l[3];
  while (scanf("%I64d %d %d", &n, &sz, &k) == 3) {
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) a[i][j] = 1, b[i][j] = (i == j);
    for (int i = 0; i < k; i++) {
      scanf("%s", l);
      int t1 = cal(l[0]), t2 = cal(l[1]);
      a[t1][t2] = 0;
    }
    for (n--; n; n >>= 1, mult(a, a))
      if (n & 1) mult(b, a);
    long long ans = 0;
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) ans = (ans + b[i][j]) % mod;
    printf("%I64d\n", ans);
  }
  return 0;
}
