#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int MOD = int(1e9) + 7;
const int N = 55;
long long int matrix[N][N], n, m, k;
map<char, int> mapping;
void matrix_multiply(long long int mat[N][N], long long int temp[N][N]) {
  long long int c[N][N] = {0};
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < m; k++) {
        c[i][j] = (c[i][j] + mat[i][k] * temp[k][j]) % MOD;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      mat[i][j] = c[i][j];
    }
  }
}
void fast_exponentiation(long long int n, long long int mat[N][N]) {
  if (n <= 1) {
    return;
  }
  long long int temp[N][N];
  for (int i = (int)0; i < (int)m; i++) {
    for (int j = (int)0; j < (int)m; j++) {
      temp[i][j] = mat[i][j];
    }
  }
  if (n & 1) {
    fast_exponentiation(n / 2, mat);
    long long int temp1[N][N];
    for (int i = (int)0; i < (int)m; i++) {
      for (int j = (int)0; j < (int)m; j++) {
        temp1[i][j] = mat[i][j];
      }
    }
    matrix_multiply(mat, temp1);
    matrix_multiply(mat, temp);
  } else {
    fast_exponentiation(n / 2, mat);
    long long int temp1[N][N];
    for (int i = (int)0; i < (int)m; i++) {
      for (int j = (int)0; j < (int)m; j++) {
        temp1[i][j] = mat[i][j];
      }
    }
    matrix_multiply(mat, temp1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (int i = (int)0; i < (int)N; i++)
    for (int j = (int)0; j < (int)N; j++) matrix[i][j] = 1;
  char ch = 'a';
  int zz = 1;
  for (; ch <= 'z'; ch++, zz++) {
    mapping[ch] = zz;
  }
  ch = 'A';
  for (; ch <= 'Z'; ch++, zz++) {
    mapping[ch] = zz;
  }
  for (int i = (int)0; i < (int)k; i++) {
    string s;
    cin >> s;
    matrix[mapping[s[0]] - 1][mapping[s[1]] - 1] = 0;
  }
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  fast_exponentiation(n - 1, matrix);
  long long int ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans = (ans + matrix[i][j]) % MOD;
  cout << ans << endl;
  return 0;
}
