#include <bits/stdc++.h>
using namespace std;
const long long Al = 53;
const long long P = 1000 * 1000 * 1000 + 7;
long long n, m, k;
struct Matrix {
  long long mat[Al][Al];
  Matrix(long long n_ = m, long long val = 1) {
    for (long long i = 0; i < n_; i++)
      for (long long j = 0; j < n_; j++) mat[i][j] = val;
  }
  Matrix operator*(const Matrix &oth) {
    Matrix ret;
    for (long long i = 0; i < m; i++)
      for (long long j = 0; j < m; j++) {
        ret.mat[i][j] = 0;
        for (long long k = 0; k < m; k++)
          ret.mat[i][j] = (ret.mat[i][j] + 1ll * mat[i][k] * oth.mat[k][j]) % P;
      }
    return ret;
  }
};
Matrix emp(Al, 0);
Matrix power(Matrix a, long long b) {
  if (b == 0) return emp;
  if (b == 1) return a;
  Matrix tmp = power(a, b / 2);
  if (b % 2 == 0) return tmp * tmp;
  return (tmp * tmp) * a;
}
long long get_num(char a) {
  if ('a' <= a && a <= 'z') return a - 'a';
  return a - 'A' + 26;
}
void read_input() {
  cin >> n >> m >> k;
  Matrix t;
  for (long long i = 0; i < k; i++) {
    string s;
    cin >> s;
    char a = s[0], b = s[1];
    long long u = get_num(a), v = get_num(b);
    t.mat[u][v] = 0;
  }
  if (n == 1) {
    cout << m << endl;
    return;
  }
  Matrix ret = power(t, n - 1);
  long long kh = 0;
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < m; j++) kh = (1ll * kh + ret.mat[i][j]) % P;
  cout << kh << endl;
}
int32_t main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input();
}
