#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long int mod = 1e9 + 7;
vector<vector<long long int>> mult(const vector<vector<long long int>>& a,
                                   const vector<vector<long long int>>& b) {
  vector<vector<long long int>> res(a.size(),
                                    vector<long long int>(b.front().size()));
  for (long long int i = 0; i < a.size(); ++i) {
    for (long long int j = 0; j < b.front().size(); ++j) {
      for (long long int k = 0; k < a.front().size(); ++k) {
        res[i][j] = (res[i][j] + (a[i][k] * b[k][j]) % mod) % mod;
      }
    }
  }
  return res;
}
vector<vector<long long int>> getE(long long int n) {
  vector<vector<long long int>> res(n, vector<long long int>(n));
  for (long long int i = 0; i < n; ++i) res[i][i] = 1;
  return res;
}
vector<vector<long long int>> fastPow(const vector<vector<long long int>>& x,
                                      long long int p) {
  if (p == 0)
    return getE(x.size());
  else if (p % 2 == 0) {
    vector<vector<long long int>> ans = fastPow(x, p / 2);
    return mult(ans, ans);
  } else {
    vector<vector<long long int>> ans = fastPow(x, p - 1);
    return mult(ans, x);
  }
}
long long int getInd(char c) {
  if (c >= 'a' && c <= 'z')
    return c - 'a';
  else
    return c - 'A' + 26;
}
signed main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long int>> mask(m, vector<long long int>(m, 1));
  for (long long int i = 0; i < k; ++i) {
    char a, b;
    cin >> a >> b;
    mask[getInd(a)][getInd(b)] = 0;
  }
  mask = fastPow(mask, n - 1);
  vector<vector<long long int>> base(m, vector<long long int>(1, 1));
  vector<vector<long long int>> ans = mult(mask, base);
  long long int res = 0;
  for (auto i : ans) {
    for (auto j : i) res = (res + j) % mod;
  }
  cout << res << "\n";
  return 0;
}
