#include <bits/stdc++.h>
using namespace std;
long long dm;
struct matrix {
  long long mat[55][55];
  matrix() { memset(mat, 0, sizeof mat); }
  matrix operator*(const matrix &a) const {
    matrix d;
    for (long long i = 0; i < dm; i++) {
      for (long long j = 0; j < dm; j++) {
        for (long long k = 0; k < dm; k++) {
          d.mat[i][j] += mat[i][k] * a.mat[k][j];
          d.mat[i][j] %= 1000000007;
        }
      }
    }
    return d;
  }
  matrix operator+(const matrix &a) const {
    matrix d;
    for (long long i = 0; i < dm; i++) {
      for (long long j = 0; j < dm; j++) {
        d.mat[i][j] += mat[i][j] + a.mat[i][j];
        d.mat[i][j] %= 1000000007;
      }
    }
    return d;
  }
  void identity() {
    for (long long i = 0; i < dm; i++) {
      mat[i][i] = 1;
    }
  }
};
matrix power(matrix &c, long long b) {
  matrix d;
  d.identity();
  while (b) {
    if (b & 1) d = d * c;
    b >>= 1;
    c = c * c;
  }
  return d;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  dm = m;
  matrix a;
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) a.mat[i][j] = 1;
  }
  while (k--) {
    string aa;
    cin >> aa;
    long long f, s;
    if (aa[0] >= 'a' and aa[0] <= 'z')
      f = aa[0] - 'a';
    else
      f = aa[0] - 'A' + 26;
    if (aa[1] >= 'a' and aa[1] <= 'z')
      s = aa[1] - 'a';
    else
      s = aa[1] - 'A' + 26;
    a.mat[f][s] = 0;
  }
  if (n == 1)
    cout << m << endl;
  else {
    a = power(a, n - 1);
    long long ans = 0;
    for (long long i = 0; i < m; i++) {
      for (long long j = 0; j < m; j++) {
        ans += a.mat[i][j];
        ans %= 1000000007;
      }
    }
    cout << ans << endl;
  }
}
