#include <bits/stdc++.h>
using namespace std;
long long n, tot;
int m, k;
char tmp[55];
struct Mat {
  long long x[55][55];
  Mat() { memset(x, 0, sizeof(x)); }
  Mat operator*(Mat a) {
    Mat re;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++)
        for (int kk = 1; kk <= m; kk++) {
          re.x[i][j] += x[i][kk] * a.x[kk][j];
          re.x[i][j] %= 1000000007;
        }
    return re;
  }
} ans, pw;
int num(char x) {
  if (x >= 'a' && x <= 'z') return x - 'a' + 1;
  return 27 + x - 'A';
}
int main() {
  while (~scanf("%I64d %d %d", &n, &m, &k)) {
    tot = 0;
    n--;
    ans = Mat();
    for (int i = 1; i <= m; i++) ans.x[i][i] = 1;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) pw.x[i][j] = 1;
    for (int i = 1; i <= k; i++) {
      scanf("%s", tmp);
      pw.x[num(tmp[0])][num(tmp[1])] = 0;
    }
    while (n) {
      if (n & 1) ans = ans * pw;
      pw = pw * pw;
      n >>= 1;
    }
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) {
        tot += ans.x[i][j];
        tot %= 1000000007;
      }
    printf("%I64d\n", tot);
  }
  return 0;
}
