#include <bits/stdc++.h>
using namespace std;
const int maxn = 52, mod = 1000000007;
long long n, m, k, ans;
string s;
struct mat {
  long long arr[maxn][maxn];
};
mat A, ret, h;
mat zarb(mat a, mat b, int M) {
  memset(ret.arr, 0, sizeof ret.arr);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < m; k++)
        ret.arr[i][k] = (ret.arr[i][k] + ((a.arr[i][j] * b.arr[j][k]) % M)) % M;
    }
  }
  return ret;
}
mat power(mat a, long long b, int M) {
  if (b == 0) return h;
  mat hlp = power(a, b / 2, M);
  if (b & 1) return zarb(zarb(hlp, hlp, M), a, M);
  return zarb(hlp, hlp, M);
}
int get(char c) {
  if (c <= 'Z') return c - 'A' + 26;
  return c - 'a';
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    h.arr[i][i] = 1;
    for (int j = 0; j < m; j++) A.arr[i][j] = 1;
  }
  for (int i = 0; i < k; i++) {
    cin >> s;
    A.arr[get(s[1])][get(s[0])] = 0;
  }
  A = power(A, n - 1, mod);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) ans = (ans + A.arr[i][j]) % mod;
  }
  cout << ans;
  return 0;
}
