#include <bits/stdc++.h>
using namespace std;
void file() {}
const long long nax = 52, mod = 1e9 + 7;
vector<vector<long long> > stoned(nax, vector<long long>(nax, 1)),
    not_stoned(nax, vector<long long>(nax, 1));
long long m;
long long conv(char c) {
  if (c >= 'a' && c <= 'z') {
    return c - 'a';
  } else {
    return c - 'A' + 26;
  }
}
void mul() {
  vector<vector<long long> > dead(nax, vector<long long>(nax));
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      for (long long k = 0; k < m; k++) {
        dead[i][j] += (stoned[i][k] * stoned[k][j]) % mod;
        dead[i][j] %= mod;
      }
    }
  }
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < m; j++) stoned[i][j] = dead[i][j];
}
void mul1() {
  vector<vector<long long> > dead(nax, vector<long long>(nax));
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      for (long long k = 0; k < m; k++) {
        dead[i][j] += (stoned[i][k] * not_stoned[k][j]) % mod;
        dead[i][j] %= mod;
      }
    }
  }
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < m; j++) stoned[i][j] = dead[i][j];
}
void just_do_it_fast(long long how_many_times) {
  if (how_many_times <= 1) return;
  just_do_it_fast(how_many_times / 2);
  mul();
  if (how_many_times % 2) mul1();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  file();
  long long n, k;
  cin >> n >> m >> k;
  if (n == 1) {
    cout << m;
    return 0;
  }
  for (long long i = 0; i < k; i++) {
    string s;
    cin >> s;
    long long a = conv(s[0]);
    long long b = conv(s[1]);
    stoned[a][b] = 0;
    not_stoned[a][b] = 0;
  }
  just_do_it_fast(n - 1);
  long long ans = 0;
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < m; j++) ans += stoned[i][j], ans %= mod;
  cout << ans;
  return 0;
}
