#include <bits/stdc++.h>
using namespace std;
const int carma = (int)'A' - 1;
const int carmi = (int)'a' - 1;
struct matrix {
  long long a[60][60];
  void f() {
    for (int i = 1; i <= 55; i++)
      for (int j = 1; j <= 55; j++) a[i][j] = 0;
  }
};
matrix operator*(matrix a, matrix b) {
  matrix res;
  res.f();
  for (int i = 1; i <= 55; i++) {
    for (int j = 1; j <= 55; j++) {
      for (int l = 1; l <= 55; l++)
        res.a[i][j] = (res.a[i][j] + a.a[i][l] * b.a[l][j]) % 1000000007;
    }
  }
  return res;
}
long long n;
int m, k;
matrix power(matrix a, long long p) {
  if (p == 1) return a;
  if (p % 2) return power(a, p - 1) * a;
  matrix t = power(a, p / 2);
  return t * t;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n >> m >> k;
  matrix G;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) G.a[i][j] = 1;
  for (int i = 1; i <= k; i++) {
    char ta, tb;
    cin >> ta >> tb;
    int a, b;
    if ((int)ta >= 97)
      a = (int)ta - carmi;
    else
      a = (int)ta - carma + 26;
    if ((int)tb >= 97)
      b = (int)tb - carmi;
    else
      b = (int)tb - carma + 26;
    G.a[a][b] = 0;
  }
  if (n == 1) {
    cout << m;
    return 0;
  }
  matrix res = power(G, n - 1);
  long long sol = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) sol = (sol + res.a[i][j]) % 1000000007;
  }
  cout << sol;
}
