#include <bits/stdc++.h>
using namespace std;
inline int idx(char c) {
  if (islower(c))
    return c - 'a';
  else
    return c - 'A' + 26;
}
int m;
long long c[55][55];
void mul(long long a[55][55], long long b[55][55]) {
  memset(c, 0, sizeof(c));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++)
        c[i][j] = (a[i][k] * b[k][j] + c[i][j]) % 1000000007;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = c[i][j];
}
long long A[55][55], X[55][55];
int main() {
  long long n;
  int k;
  cin >> n >> m >> k;
  n--;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) X[i][j] = 1;
  while (k--) {
    char a, b;
    scanf(" %c%c", &a, &b);
    X[idx(a)][idx(b)] = 0;
  }
  for (int i = 0; i < m; i++) A[i][i] = 1;
  for (long long i = 1; i <= n; i *= 2) {
    if (n & i) mul(A, X);
    mul(X, X);
  }
  long long ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans += A[i][j];
  ans %= 1000000007;
  cout << ans << endl;
  return 0;
}
