#include <bits/stdc++.h>
using namespace std;
const long mod = 1000000007;
long a[55][55] = {0};
long b[55][55] = {0};
long c[55][55] = {0};
long get(char ch) {
  if (ch <= 'Z')
    return 27 + ch - 'A';
  else
    return 1 + ch - 'a';
}
void mul(long long y, long n) {
  long i, j, k;
  for (i = 1; i <= n; i++) b[i][i] = 1;
  for (; y; y >>= 1) {
    if (y & 1) {
      for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
          for (k = 1, c[i][j] = 0; k <= n; k++) {
            c[i][j] += (long long)b[i][k] * a[k][j] % mod;
            c[i][j] %= mod;
          }
      for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++) b[i][j] = c[i][j];
    }
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        for (k = 1, c[i][j] = 0; k <= n; k++) {
          c[i][j] += (long long)a[i][k] * a[k][j] % mod;
          c[i][j] %= mod;
        }
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) a[i][j] = c[i][j];
  }
}
int main() {
  long m, k;
  long long n;
  long long ans = 0;
  scanf("%I64d%ld%ld", &n, &m, &k);
  long i, j;
  for (i = 1; i <= m; i++)
    for (j = 1; j <= m; j++) a[i][j] = 1;
  for (; k; k--) {
    char ch[5] = {0};
    scanf("%s", ch);
    a[get(ch[0])][get(ch[1])] = 0;
  }
  mul(n - 1, m);
  for (i = 1; i <= m; i++)
    for (j = 1; j <= m; j++) ans += b[i][j];
  printf("%I64d\n", ans % mod);
  return 0;
}
