#include <bits/stdc++.h>
using namespace std;
const int NUM = 52;
const int MOD = 1000000007;
struct matrix {
  int dd[NUM][NUM], n;
  matrix() {}
  matrix(int x) {
    memset(dd, 0, sizeof(dd));
    for (int i = 0; i < NUM; ++i) dd[i][i] = x;
  }
  matrix operator*(const matrix &w) const {
    matrix res(0);
    res.n = n;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        for (int k = 0; k < n; ++k) {
          res.dd[i][j] =
              (res.dd[i][j] + (long long)dd[i][k] * w.dd[k][j]) % MOD;
        }
    return res;
  }
  matrix operator^(long long x) {
    matrix res(1), tt(*this);
    res.n = n;
    while (x) {
      if (x & 1) res = res * tt;
      tt = tt * tt;
      x >>= 1;
    }
    return res;
  }
};
int getit(char c) {
  if (c >= 'a' && c <= 'z') return c - 'a';
  return c - 'A' + 26;
}
int main() {
  long long n;
  int m, k;
  cin >> n >> m >> k;
  char a, b;
  matrix bb(0);
  bb.n = m;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) bb.dd[i][j] = 1;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    bb.dd[getit(a)][getit(b)] = 0;
  }
  matrix res = bb ^ (n - 1);
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) ans = (ans + res.dd[i][j]) % MOD;
  }
  cout << ans << endl;
  return 0;
}
