#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MAXN = 60;
long long n;
long long m, k, matrix[MAXN][MAXN];
void mul(long long n, long long x[][MAXN], long long y[][MAXN]) {
  long long temp[MAXN][MAXN];
  memset(temp, 0, sizeof(temp));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++)
        temp[i][j] = (x[i][k] * y[k][j] + temp[i][j]) % MOD;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) x[i][j] = temp[i][j];
}
void quick_exp(long long m, long long x[][MAXN], long long n) {
  long long temp[MAXN][MAXN];
  memset(temp, 0, sizeof(temp));
  for (int i = 0; i < m; i++) temp[i][i] = 1;
  while (n) {
    int a = n % 2;
    if (a) mul(m, temp, x);
    mul(m, x, x);
    n >>= 1;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) x[i][j] = temp[i][j];
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) matrix[i][j] = 1;
  for (int i = 1; i <= k; i++) {
    char a, b, str[3];
    int x, y;
    cin >> str;
    a = str[0], b = str[1];
    if (a >= 'a' && a <= 'z')
      x = a - 'a';
    else
      x = a - 'A' + 26;
    if (b >= 'a' && b <= 'z')
      y = b - 'a';
    else
      y = b - 'A' + 26;
    matrix[x][y] = 0;
  }
  quick_exp(m, matrix, n - 1);
  long long ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans = (ans + matrix[i][j]) % MOD;
  cout << ans << endl;
  return 0;
}
