#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int MAXN = 60;
long long n, m, u;
struct matrix {
  long long a[MAXN][MAXN];
  matrix operator*(const matrix &b) const {
    matrix c;
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) {
        c.a[i][j] = 0;
        for (int k = 0; k < m; k++)
          c.a[i][j] = (c.a[i][j] + ((a[i][k] * b.a[k][j]) % mod)) % mod;
      }
    return c;
  }
} mat, h;
int ch(char a) {
  if (a >= 97) return a - 'a';
  return a - 'A' + 26;
}
matrix get(long long n, const matrix &x) {
  if (n == 0) return h;
  matrix y = get(n / 2, x);
  return (y * y) * ((n % 2) ? x : h);
}
int main() {
  scanf("%lld %lld %lld", &n, &m, &u);
  for (int i = 0; i < u; i++) {
    char a, b;
    scanf(" %c%c", &a, &b);
    int ap = ch(a), bp = ch(b);
    mat.a[ap][bp] = -1;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) mat.a[i][j]++;
  for (int i = 0; i < m; i++) h.a[i][i] = 1;
  mat = get(n - 1, mat);
  long long ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans = (ans + mat.a[i][j]) % mod;
  printf("%lld\n", ans);
}
