#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7, N = 60;
typedef long long mat[N][N];
mat a, b, c;
long long n, m, k, ans;
string s;
void mul(mat a, mat b, mat c) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) c[i][j] = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++) {
        c[i][k] += a[i][j] * b[j][k];
        c[i][k] %= MOD;
      }
}
int f(char c) {
  if (c >= 'a' && c <= 'z') return c - 'a';
  return c - 'A' + 26;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = 1;
  for (int i = 0; i < k; i++) {
    cin >> s;
    a[f(s[0])][f(s[1])] = 0;
  }
  for (int i = 0; i < m; i++) b[i][i] = 1;
  n--;
  for (; n; n /= 2) {
    if (n & 1) {
      mul(a, b, c);
      swap(b, c);
    }
    mul(a, a, c);
    swap(a, c);
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      ans += b[i][j];
      ans %= MOD;
    }
  cout << ans;
  return 0;
}
