#include <bits/stdc++.h>
using namespace std;
int nextint() {
  int t;
  scanf("%d", &t);
  return t;
}
const int SZ = 52;
const unsigned long long MOD = 1000000007;
unsigned long long a[SZ][SZ];
unsigned long long b[SZ][SZ];
unsigned long long tmp[SZ][SZ];
int m;
void mul(unsigned long long a[SZ][SZ], unsigned long long b[SZ][SZ],
         unsigned long long res[SZ][SZ]) {
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (m); j++) {
      tmp[i][j] = 0;
      for (int k = 0; k < (m); k++) {
        tmp[i][j] += a[i][k] * b[k][j];
        if ((k & 7) == 7) tmp[i][j] %= MOD;
      }
    }
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (m); j++) res[i][j] = tmp[i][j] % MOD;
}
unsigned long long solve(unsigned long long n) {
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (m); j++) {
      a[i][j] = (i == j);
    }
  while (n) {
    if (n & 1) mul(a, b, a);
    mul(b, b, b);
    n >>= 1;
  }
  unsigned long long res = 0;
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (m); j++) res += a[i][j];
  return res % MOD;
}
char buf[100];
int decode(char c) {
  if ('a' <= c && c <= 'z')
    return c - 'a';
  else
    return c - 'A' + 26;
}
int main() {
  unsigned long long n;
  int k;
  cin >> n;
  n--;
  cin >> m;
  cin >> k;
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (m); j++) {
      b[i][j] = 1;
    }
  for (int i = 0; i < (k); i++) {
    scanf("%s", buf);
    b[decode(buf[0])][decode(buf[1])] = 0;
  }
  cout << solve(n) << endl;
  return 0;
}
