#include <bits/stdc++.h>
using namespace std;
long long stop[52][52] = {1};
long long mod = 1000000007;
char trans(int a) {
  if (a >= 1 && a <= 26)
    return 'a' + a - 1;
  else
    return 'A' + a - 1;
}
int intr(char a) {
  if (a >= 'A' && a <= 'Z')
    return a - 'A' + 26;
  else if (a >= 'a' && a <= 'z')
    return a - 'a';
}
long long e[52][52] = {0};
long long m;
void mul(long long a[52][52], long long b[52][52], long long c[52][52]) {
  long long _[52][52] = {0};
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++)
        _[i][j] = (_[i][j] + (long long)a[i][k] * b[k][j]) % mod;
  memcpy(c, _, sizeof _);
}
void powm(long long n) {
  long long c[52][52] = {0};
  while (n) {
    if (n & 1) {
      mul(e, stop, e);
    }
    mul(stop, stop, stop);
    n >>= 1;
  }
}
int main() {
  long long n, k;
  cin >> n >> m >> k;
  for (int i = 0; i < 52; i++) {
    for (int j = 0; j < 52; j++) {
      stop[i][j] = 1;
      e[0][j] = 1;
    }
  }
  if (n == 1) {
    cout << m;
    return 0;
  }
  getchar();
  for (int i = 0; i < k; i++) {
    char c1, c2;
    scanf("%c%c\n", &c1, &c2);
    stop[intr(c1)][intr(c2)] = 0;
  }
  powm(n - 1);
  long long ans = 0;
  for (int j = 0; j < m; j++) {
    ans += e[0][j];
    ans %= mod;
  }
  cout << ans;
  return 0;
}
