#include <bits/stdc++.h>
using namespace std;
const long long int mx = 53, Mod = 1e9 + 7;
long long int n, m, k;
struct Matrix {
  int w = m, h = m;
  int val[mx][mx];
  Matrix(int _h = mx, int _w = mx, int _base = 0) {
    h = _h;
    w = _w;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) val[i][j] = (i == j ? _base : 0);
  }
  int* operator[](int x) { return val[x]; }
  void print() {
    cout << "Matrix::print() {\n";
    for (int i = 0; i < m; i++) {
      cout << "    ";
      for (int j = 0; j < m; j++) cout << val[i][j] << ' ';
      cout << '\n';
    }
    cout << "}\n";
  }
};
Matrix operator*(Matrix a, Matrix b) {
  Matrix res;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++)
        res[i][k] = (res[i][k] + 1LL * a[i][j] * b[j][k]) % Mod;
  return res;
}
int get(char c) {
  if (c >= 'a')
    return c - 'a';
  else
    return c - 'A' + 26;
}
Matrix dp[mx];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) dp[0][i][j] = 1;
  string s;
  for (int i = 0; i < k; i++) {
    cin >> s;
    dp[0][get(s[0])][get(s[1])] = 0;
  }
  for (int l = 1; l < mx; l++) dp[l] = dp[l - 1] * dp[l - 1];
  Matrix res(m, m, 1);
  n--;
  for (int i = 0; i < mx; i++)
    if (((n >> i) & 1)) res = res * dp[i];
  long long int ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans += res[i][j], ans %= Mod;
  cout << ans << '\n';
  return 0;
}
