#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
vector<vector<long long> > mul(vector<vector<long long> > a,
                               vector<vector<long long> > b) {
  int m = a.size();
  vector<vector<long long> > res(m, vector<long long>(m, 0));
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j)
      for (int k = 0; k < m; ++k)
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % mod;
  return res;
}
vector<vector<long long> > pow(vector<vector<long long> > a, long long n) {
  int m = a.size();
  vector<vector<long long> > res(m, vector<long long>(m, 0));
  for (int i = 0; i < m; ++i) res[i][i] = 1;
  if (n == 0) return res;
  if (n % 2 == 1) return mul(pow(a, n - 1), a);
  res = pow(a, n / 2);
  return mul(res, res);
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long> > a(m, vector<long long>(m, 1));
  for (size_t i = 0; i < k; ++i) {
    string s;
    cin >> s;
    int x, y;
    if ('a' <= s[0] && s[0] <= 'z')
      x = s[0] - 'a';
    else
      x = 26 + s[0] - 'A';
    if ('a' <= s[1] && s[1] <= 'z')
      y = s[1] - 'a';
    else
      y = 26 + s[1] - 'A';
    a[x][y] = 0;
  }
  vector<vector<long long> > b = pow(a, n - 1);
  long long res = 0;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) res = (res + b[i][j]) % mod;
  cout << res << endl;
  return 0;
}
