#include <bits/stdc++.h>
using namespace std;
int matriz[52][52], m;
int pow_result[52][52];
int mult_result[52][52];
void multiply(int m1[52][52], int m2[52][52]) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) {
      mult_result[i][j] = 0;
      for (int k = 0; k < m; ++k) {
        mult_result[i][j] += m1[i][k] * 1LL * m2[k][j] % 1000000007;
        mult_result[i][j] %= 1000000007;
      }
    }
}
void pow(int b[52][52], long long e) {
  if (e == 0) {
    memset(pow_result, 0, sizeof pow_result);
    for (int i = 0; i < 52; ++i) pow_result[i][i] = 1;
  } else {
    pow(b, e / 2);
    multiply(pow_result, pow_result);
    memcpy(pow_result, mult_result, sizeof pow_result);
    if (e % 2) {
      multiply(pow_result, matriz);
      memcpy(pow_result, mult_result, sizeof pow_result);
    }
  }
}
int main() {
  int i, j, k, indexes['z' + 1], answer;
  long long n;
  char c, restriction[3];
  for (c = 'a'; c <= 'z'; ++c) indexes[c] = c - 'a';
  for (c = 'A'; c <= 'Z'; ++c) indexes[c] = c - 'A' + 26;
  scanf("%I64d%d%d", &n, &m, &k);
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) matriz[i][j] = 1;
  while (k--) {
    scanf("%s", restriction);
    matriz[indexes[restriction[0]]][indexes[restriction[1]]] = 0;
  }
  pow(matriz, n - 1);
  answer = 0;
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) answer = (answer + pow_result[i][j]) % 1000000007;
  printf("%d", answer);
  return 0;
}
