#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, M = 52;
void mul(long long f[M + 5], long long a[M + 5][M + 5], int m) {
  long long c[M + 5];
  memset(c, 0, sizeof(c));
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) c[i] = (c[i] + f[j] * a[j][i]) % P;
  memcpy(f, c, sizeof(c));
  return;
}
void mulself(long long a[M + 5][M + 5], int m) {
  long long c[M + 5][M + 5];
  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] = (c[i][j] + (a[i][k] * a[k][j]) % P) % P;
  memcpy(a, c, sizeof(c));
  return;
}
void Fastmul(long long ans[M + 5], long long a[M + 5][M + 5], long long k,
             int m) {
  while (k > 0) {
    if (k & 1) mul(ans, a, m);
    mulself(a, m);
    k >>= 1;
  }
  return;
}
int CHG(char ch) {
  if (ch <= 'z' && ch >= 'a')
    return ch - 'a';
  else
    return ch - 'A' + 26;
}
int main() {
  long long n;
  int m, k;
  cin >> n >> m >> k;
  long long a[M + 5][M + 5];
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= k; ++i) {
    string st;
    cin >> st;
    a[CHG(st[0])][CHG(st[1])] = -1;
  }
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) a[i][j] += 1;
  long long ans[M + 5];
  for (int i = 0; i < m; ++i) ans[i] = 1;
  Fastmul(ans, a, n - 1, m);
  long long Ans = 0;
  for (int i = 0; i < m; ++i) {
    Ans = (ans[i] + Ans) % P;
  }
  cout << Ans << '\n';
  return 0;
}
