#include <bits/stdc++.h>
using namespace std;
struct M {
  long long a[55][55];
} p;
long long n;
int m, k;
char s[11];
int mod = 1000000007;
M mul(M a, M b) {
  M c;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      c.a[i][j] = 0;
      for (int k = 0; k < m; k++) {
        c.a[i][j] += a.a[i][k] * b.a[k][j];
        c.a[i][j] %= mod;
      }
    }
  return c;
}
M powm(M t, long long pp) {
  if (pp == 1) return t;
  if (pp % 2 == 0) {
    M tm = powm(t, pp / 2);
    return mul(tm, tm);
  }
  return mul(t, powm(t, pp - 1));
}
int main() {
  scanf("%I64d%d%d", &n, &m, &k);
  if (n == 1) {
    printf("%d\n", m);
    return 0;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) p.a[i][j] = 1;
  for (int i = 0; i < k; i++) {
    scanf("%s", s);
    int t[2];
    for (int j = 0; j < 2; j++)
      if (s[j] >= 'A' && s[j] <= 'Z')
        t[j] = s[j] - 'A' + 26;
      else
        t[j] = s[j] - 'a';
    p.a[t[0]][t[1]] = 0;
  }
  p = powm(p, n - 1);
  long long ret = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      ret += p.a[i][j];
      ret %= mod;
    }
  }
  printf("%I64d\n", ret);
}
