#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int type;
const long long int mod = 1e9 + 7;
long long C[N][N];
void matrix_mul(long long A[N][N], long long B[N][N]) {
  for (int i = 0; i < type; i++) {
    for (int j = 0; j < type; j++) {
      C[i][j] = 0;
      for (int k = 0; k < type; k++) {
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
      }
    }
  }
  for (int i = 0; i < type; i++) {
    for (int j = 0; j < type; j++) {
      A[i][j] = C[i][j];
    }
  }
}
void pow(long long A[N][N], long long m) {
  long long res[N][N];
  memset(res, 0, sizeof(res));
  for (int i = 0; i < type; i++) res[i][i] = 1;
  while (m) {
    if (m & 1) matrix_mul(res, A);
    matrix_mul(A, A);
    m >>= 1;
  }
  for (int i = 0; i < type; i++) {
    for (int j = 0; j < type; j++) {
      A[i][j] = res[i][j];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  type = m;
  long long M[N][N];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) M[i][j] = 1;
  while (k--) {
    string str;
    cin >> str;
    char x1 = str[0];
    int x1n;
    char x2 = str[1];
    int x2n;
    if (x1 >= 'a' && x1 <= 'z')
      x1n = x1 - 'a';
    else if (x1 >= 'A' && x1 <= 'Z')
      x1n = x1 - 'A' + 26;
    if (x2 >= 'a' && x2 <= 'z')
      x2n = x2 - 'a';
    else if (x2 >= 'A' && x2 <= 'Z')
      x2n = x2 - 'A' + 26;
    M[x1n][x2n] = 0;
  }
  pow(M, n - 1);
  long long sum = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) sum = (sum + M[i][j]) % mod;
  cout << sum << endl;
  return 0;
}
