#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int M = 60;
int m;
void mul(int a[][M], int b[][M]) {
  static int ret[M][M];
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) {
      ret[i][j] = 0;
      for (int k = 0; k < m; ++k)
        ret[i][j] = (ret[i][j] + (long long)a[i][k] * b[k][j]) % MOD;
    }
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) a[i][j] = ret[i][j];
}
void pow(int a[][M], int ans[][M], long long n) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) ans[i][j] = 0;
  for (int i = 0; i < m; ++i) ans[i][i] = 1;
  while (n) {
    if (n & 1) mul(ans, a);
    mul(a, a);
    n >>= 1;
  }
}
int a[M][M], ans[M][M];
int getc(char t) {
  if (t >= 'a' && t <= 'z') return t - 'a';
  return t - 'A' + 26;
}
int main() {
  long long n;
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) a[i][j] = 1;
  char str[10];
  while (k--) {
    cin >> str;
    a[getc(str[0])][getc(str[1])] = 0;
  }
  pow(a, ans, n - 1);
  int res = 0;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) res = (res + ans[i][j]) % MOD;
  cout << res << endl;
  return 0;
}
