#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
struct matrix {
  int n;
  long long ar[53][53];
  matrix(int nn, long long x) {
    n = nn;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (i == j)
          ar[i][j] = x;
        else
          ar[i][j] = 0;
  }
  long long* operator[](int x) { return ar[x]; }
};
matrix operator*(matrix a, matrix b) {
  matrix ret(a.n, 0);
  for (int i = 0; i < a.n; i++)
    for (int j = 0; j < a.n; j++)
      for (int k = 0; k < a.n; k++)
        ret[i][j] += a[i][k] * b[k][j], ret[i][j] %= MOD;
  return ret;
}
matrix operator^(matrix a, long long n) {
  matrix res(a.n, 1);
  if (!n) return res;
  res = a ^ (n >> 1);
  if (n & 1) return res * res * a;
  return res * res;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  matrix ans(m, 0);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans[i][j] = 1;
  for (int i = 0; i < k; i++) {
    int id1, id2;
    char ch1, ch2;
    cin >> ch1 >> ch2;
    if (ch1 >= 'a' && ch1 <= 'z')
      id1 = ch1 - 'a';
    else
      id1 = ch1 - 'A' + 26;
    if (ch2 >= 'a' && ch2 <= 'z')
      id2 = ch2 - 'a';
    else
      id2 = ch2 - 'A' + 26;
    ans[id1][id2] = 0;
  }
  ans = ans ^ (n - 1);
  long long ret = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ret = (ret + ans[i][j]) % MOD;
  cout << ret << endl;
  return 0;
}
