#include <bits/stdc++.h>
using namespace std;
const int MODULO = 1000000007;
const int INF = 100000000;
vector<vector<long long> > mul(const vector<vector<long long> >& a,
                               const vector<vector<long long> >& b) {
  int n = a.size();
  vector<vector<long long> > c(n, vector<long long>(n));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k) (c[i][j] += a[i][k] * b[k][j]) %= MODULO;
  return c;
}
vector<vector<long long> > pow(const vector<vector<long long> >& _a,
                               long long e) {
  vector<vector<long long> > a = _a;
  int n = a.size();
  vector<vector<long long> > res(n, vector<long long>(n));
  for (int i = 0; i < n; ++i) res[i][i] = 1;
  while (e > 0) {
    if (e & 1) res = mul(res, a);
    a = mul(a, a);
    e /= 2;
  }
  return res;
}
int get_num(char c) {
  if ('a' <= c && c <= 'z')
    return c - 'a';
  else
    return c - 'A' + 26;
}
int main() {
  long long n;
  int m, k;
  cin >> n >> m >> k;
  vector<vector<long long> > mat(m, vector<long long>(m + 1, 1LL));
  mat.push_back(vector<long long>(m + 1, 0));
  for (int i = 0; i < (k); i++) {
    char c1, c2;
    scanf(" %c%c", &c1, &c2);
    mat[get_num(c1)][get_num(c2)] = 0;
  }
  vector<vector<long long> > ret = pow(mat, n);
  long long ans = 0;
  for (int i = 0; i < (m); i++) {
    ans += ret[i][m];
  }
  cout << ans % MODULO << endl;
  return 0;
}
