#include <bits/stdc++.h>
long long N, M, K, A[52][52], B[52][52];
void mul(long long A[52][52], long long B[52][52]) {
  long long C[52][52] = {};
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++)
      for (int k = 0; k < M; k++)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % 1000000007;
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) A[i][j] = C[i][j];
}
int main() {
  scanf("%I64d%I64d%I64d", &N, &M, &K);
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) A[i][j] = i == j, B[i][j] = 1;
  for (int i = 0; i < K; i++) {
    char c[3];
    scanf("%s", c);
    B[c[0] - (c[0] > 96 ? 97 : 39)][c[1] - (c[1] > 96 ? 97 : 39)] = 0;
  }
  for (N--; N; N >>= 1) {
    if (N & 1) mul(A, B);
    mul(B, B);
  }
  int res = 0;
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) res = (res + A[i][j]) % 1000000007;
  printf("%d\n", res);
}
