#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
long long n, m, k;
vector<vector<long long> > A;
vector<vector<long long> > ZARB(const vector<vector<long long> > &x,
                                const vector<vector<long long> > &y) {
  vector<vector<long long> > q;
  q.resize(m);
  for (int i = 0; i < m; i++) q[i].resize(m);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++) {
        q[i][j] += x[i][k] * y[k][j];
        if (q[i][j] > MOD) q[i][j] %= MOD;
      }
  return q;
}
vector<vector<long long> > POW(long long num) {
  if (num == 1) return A;
  vector<vector<long long> > mid = POW(num / 2);
  if (num % 2) return ZARB(ZARB(mid, mid), A);
  return ZARB(mid, mid);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  A.resize(m);
  for (int i = 0; i < m; i++) A[i].resize(m);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) A[i][j] = 1;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    int q1, q2;
    if (s[0] < 'a')
      q1 = s[0] - 'A' + 26;
    else
      q1 = s[0] - 'a';
    if (s[1] < 'a')
      q2 = s[1] - 'A' + 26;
    else
      q2 = s[1] - 'a';
    A[q2][q1] = 0;
  }
  if (n == 1) {
    cout << m;
    return 0;
  }
  vector<vector<long long> > help = POW(n - 1);
  vector<vector<long long> > M;
  M.resize(m);
  for (int i = 0; i < m; i++) M[i].resize(m);
  for (int i = 0; i < m; i++) M[i][0] = 1;
  vector<vector<long long> > ans = ZARB(help, M);
  long long rr = 0;
  for (int i = 0; i < m; i++) rr = (rr + ans[i][0]) % MOD;
  cout << rr;
  return 0;
}
