#include <bits/stdc++.h>
using namespace std;
struct matrix {
  int N;
  long long int v[110][110];
  matrix(int n = 0) : N(n) { memset(v, 0, sizeof(v)); }
  matrix operator*(matrix& k) {
    matrix ans(N);
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        for (int p = 1; p <= N; p++) {
          ans.v[i][j] += v[i][p] * k.v[p][j];
          ans.v[i][j] %= 1000000007;
        }
      }
    }
    return ans;
  }
};
int m, k;
long long int n;
char a, b;
matrix expo;
long long int fastExpo(matrix& k, long long int e) {
  matrix ans(m);
  for (int i = 1; i <= m; i++) ans.v[i][i] = 1;
  for (long long int l = 60; l >= 0; l--) {
    ans = ans * ans;
    if (e & (1LL << l)) ans = ans * k;
  }
  long long int sum = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) sum += ans.v[i][j];
  return sum % 1000000007;
}
int conv(char k) {
  if ('a' <= k && k <= 'z') return k - 'a' + 1;
  return k - 'A' + 1 + 26;
}
int main() {
  scanf("%lld %d %d", &n, &m, &k);
  expo.N = m;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) expo.v[i][j] = 1;
  for (int i = 0; i < k; i++) {
    scanf(" %c %c", &a, &b);
    int n1 = conv(a);
    int n2 = conv(b);
    expo.v[n1][n2] = 0;
  }
  if (n == 1) {
    printf("%d\n", m);
    return 0;
  }
  printf("%lld\n", fastExpo(expo, n - 1));
}
