#include <bits/stdc++.h>
using namespace std;
template <typename T, unsigned S>
inline unsigned arraysize(const T (&v)[S]) {
  return S;
}
int m, k;
long long n;
inline int get_id(char c) { return islower(c) ? c - 'a' : c - 'A' + 26; }
typedef int mat[52][52];
typedef int (*pmat)[52];
void multiply(pmat res, pmat a, pmat b) {
  memset(res, 0, sizeof(mat));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int l = 0; l < m; l++)
        res[i][j] = (res[i][j] + (long long)a[i][l] * b[l][j]) % 1000000007;
}
int main() {
  cin >> n >> m >> k;
  mat m1 = {{0}}, m2, m3;
  pmat res, x, temp;
  res = m1;
  x = m2;
  temp = m3;
  for (int i = 0; i < m; i++) {
    res[i][i] = 1;
  }
  for (int i = 0; i < m; i++) {
    fill_n(x[i], m, 1);
  }
  char a, b;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    x[get_id(a)][get_id(b)] = 0;
  }
  n -= 1;
  while (n) {
    if (n & 1) {
      multiply(temp, res, x);
      swap(res, temp);
    }
    multiply(temp, x, x);
    swap(x, temp);
    n >>= 1;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      ans = (ans + res[i][j]) % 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
