#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000007;
int a[52][52], b[52][52], c[52][52];
long long n;
int m, K, result;
int zhuan(char c) {
  if ((c >= 'a') && (c <= 'z'))
    return c - 'a';
  else
    return 26 + (c - 'A');
}
void init() {
  int i, j;
  scanf("%I64d%d%d", &n, &m, &K);
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) a[i][j] = 1;
  for (i = 0; i < K; ++i) {
    char s[10];
    scanf("%s", s);
    a[zhuan(s[0])][zhuan(s[1])] = 0;
  }
}
void cheng(int a[52][52], int b[52][52], int c[52][52]) {
  int i, j, k;
  long long t;
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) {
      c[i][j] = 0;
      for (k = 0; k < m; ++k) {
        t = (long long)a[i][k] * b[k][j];
        t = t % mo;
        c[i][j] += t;
        if (c[i][j] >= mo) c[i][j] -= mo;
      }
    }
}
void gei(int a[52][52], int b[52][52]) {
  int i, j;
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) a[i][j] = b[i][j];
}
void mi(long long x) {
  int i, j;
  bool first = true;
  gei(b, a);
  while (x) {
    if (x & 1) {
      if (first) {
        gei(a, b);
        first = false;
      } else {
        cheng(a, b, c);
        gei(a, c);
      }
    }
    x = (x >> 1);
    cheng(b, b, c);
    gei(b, c);
  }
}
void work() {
  int i, j;
  if (n == 1)
    result = m;
  else {
    mi(n - 1);
    for (i = 0; i < m; ++i)
      for (j = 0; j < m; ++j) {
        result += a[i][j];
        if (result >= mo) result -= mo;
      }
  }
}
void output() { printf("%d\n", result); }
int main() {
  init();
  work();
  output();
  return 0;
}
