#include <bits/stdc++.h>
long long int N;
int W, K;
unsigned long long int matriz[100][100];
unsigned long long int matrizPot[100][100];
unsigned long long int aux[100][100];
void Potencia(long long int x) {
  if (x < 2) return;
  if ((x % 2)) {
    Potencia(x - 1);
    for (int i = 0; i < W; i++)
      for (int j = 0; j < W; j++)
        for (int k = 0; k < W; k++)
          aux[i][j] = (aux[i][j] + matriz[k][j] * matrizPot[i][k]) % 1000000007;
  } else {
    Potencia(x / 2);
    for (int i = 0; i < W; i++)
      for (int j = 0; j < W; j++)
        for (int k = 0; k < W; k++)
          aux[i][j] =
              (aux[i][j] + matrizPot[k][j] * matrizPot[i][k]) % 1000000007;
  }
  for (int i = 0; i < W; i++)
    for (int j = 0; j < W; j++) {
      matrizPot[i][j] = aux[i][j];
      aux[i][j] = 0;
      if (matrizPot[i][j] >= 1000000007) matrizPot[i][j] %= 1000000007;
    }
}
int main() {
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++) matriz[i][j] = matrizPot[i][j] = 1;
  scanf("%I64d %d %d", &N, &W, &K);
  for (int i = 1; i <= K; i++) {
    char a, b;
    scanf(" %c %c", &a, &b);
    if (a >= 'A' && a <= 'Z')
      a -= 'A' - 26;
    else
      a -= 'a';
    if (b >= 'A' && b <= 'Z')
      b -= 'A' - 26;
    else
      b -= 'a';
    matriz[a][b] = matrizPot[a][b] = 0;
  }
  Potencia(N - 1);
  long long int answer = 0;
  for (int i = 0; i < W; i++)
    for (int j = 0; j < W; j++)
      answer = (answer + matrizPot[i][j]) % 1000000007;
  if (N == 1) answer = W;
  printf("%I64d\n", answer);
  return 0;
}
