#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = 52;
const int mod = (int)1e9 + 7;
char s[11];
int a[maxn][maxn], t[maxn][maxn], res[maxn][maxn], m;
void mul(int A[maxn][maxn], int B[maxn][maxn], int C[maxn][maxn]) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      t[i][j] = 0;
      for (int k = 0; k < m; k++)
        t[i][j] = (t[i][j] + (long long)A[i][k] * B[k][j]) % mod;
    }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) C[i][j] = t[i][j];
}
void binpow(long long n) {
  for (int i = 0; i < m; i++) res[i][i] = 1;
  while (n > 0) {
    if (n & 1) mul(res, a, res);
    mul(a, a, a);
    n >>= 1;
  }
}
int main() {
  long long n;
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = 1;
  for (int i = 0; i < k; i++) {
    scanf("%s", &s);
    int x, y;
    if (s[0] >= 'a' && s[0] <= 'z')
      x = s[0] - 'a';
    else
      x = s[0] - 'A' + 26;
    if (s[1] >= 'a' && s[1] <= 'z')
      y = s[1] - 'a';
    else
      y = s[1] - 'A' + 26;
    a[x][y] = 0;
  }
  binpow(n - 1);
  int ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) ans = (ans + res[i][j]) % mod;
  cout << ans;
  return 0;
}
