#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int m;
const int mod = 1000000007;
struct matr {
  int a[60][60];
  matr() { memset(a, 0, sizeof(a)); }
};
matr mul(matr m1, matr m2) {
  matr res;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j)
      for (int k = 0; k < m; ++k)
        res.a[i][j] = (res.a[i][j] + (long long)m1.a[i][k] * m2.a[k][j]) % mod;
  return res;
}
matr pow(matr x, long long p) {
  if (p == 0) {
    matr res;
    for (int i = 0; i < m; ++i) res.a[i][i] = 1;
    return res;
  } else if (p & 1)
    return mul(x, pow(x, p - 1));
  else {
    matr t = pow(x, p >> 1);
    return mul(t, t);
  }
}
int g(char c) {
  if (c >= 'a' && c <= 'z')
    return c - 'a';
  else
    return c - 'A' + 26;
}
int main() {
  long long n;
  int k;
  cin >> n >> m >> k;
  n--;
  matr p;
  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) {
    string s;
    cin >> s;
    int v1 = g(s[0]);
    int v2 = g(s[1]);
    p.a[v2][v1] = 0;
  }
  p = pow(p, n);
  int ans = 0;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) ans = (ans + p.a[i][j]) % mod;
  printf("%d\n", ans);
  return 0;
}
