#include <bits/stdc++.h>
typedef long long T[52][52];
long long N;
int r, M, K, m = 1000000007;
T A, B;
void mul(T A, T B) {
  T C = {};
  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]) % m;
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) A[i][j] = C[i][j];
}
int main() {
  scanf("%I64d%d%d", &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;
  char x, y;
  for (int i = 0; i < K; i++) {
    scanf(" %c%c", &x, &y);
    B[x - (x > 96 ? 97 : 39)][y - (y > 96 ? 97 : 39)] = 0;
  }
  for (N--; N; N >>= 1) {
    if (N & 1) mul(A, B);
    mul(B, B);
  }
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) r = (r + A[i][j]) % m;
  printf("%d\n", r);
}
