#include <bits/stdc++.h>
struct MATRIX {
  int v[52][52];
  int c, r;
};
void print(MATRIX *m) {
  for (int i = 0; i < m->c; i++) {
    for (int j = 0; j < m->r; j++) printf("%d ", m->v[i][j]);
    printf("\n");
  }
  printf("\n");
}
void multiply(MATRIX *a, MATRIX *b, MATRIX *p) {
  if (a->r != b->c) return;
  MATRIX dst;
  dst.c = a->c;
  dst.r = b->r;
  for (int i = 0; i < dst.c; i++)
    for (int j = 0; j < dst.r; j++) dst.v[i][j] = 0;
  for (int i = 0; i < dst.c; i++)
    for (int j = 0; j < dst.r; j++)
      for (int k = 0; k < a->r; k++)
        dst.v[i][j] = (int)(((long long)dst.v[i][j] +
                             (long long)a->v[i][k] * (long long)b->v[k][j]) %
                            1000000007ll);
  memcpy(p, &dst, sizeof(MATRIX));
}
MATRIX t[64];
unsigned long long val[64];
void matrix_pow(MATRIX *a, unsigned long long times, MATRIX *p) {
  MATRIX dst;
  if (a->c != a->r || times < 0) return;
  memcpy(&t[0], a, sizeof(MATRIX));
  for (int i = 0; i < 63; i++) {
    multiply(&t[i], &t[i], &t[i + 1]);
  }
  int flag = true;
  for (int i = 63; i >= 0; i--)
    if (times >= val[i]) {
      times -= val[i];
      if (flag) {
        flag = false;
        memcpy(&dst, &t[i], sizeof(MATRIX));
      } else
        multiply(&dst, &t[i], &dst);
    }
  memcpy(p, &dst, sizeof(MATRIX));
}
int getIndex(char c) {
  if (c >= 'a' && c <= 'z')
    return c - 'a';
  else if (c >= 'A' && c <= 'Z')
    return c - 'A' + 26;
  return -1;
}
int main() {
  val[0] = 1;
  for (int i = 1; i < 64; i++) val[i] = val[i - 1] << 1;
  int m, k;
  unsigned long long n;
  MATRIX a;
  scanf("%I64u%d%d", &n, &m, &k);
  if (n == 1) {
    for (int i = 0; i < k; i++) {
      char s[3];
      scanf("%s", s);
    }
    printf("%d\n", m);
  } else {
    a.r = m;
    a.c = m;
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) a.v[i][j] = 1;
    for (int i = 0; i < k; i++) {
      char s[3];
      scanf("%s", s);
      a.v[getIndex(s[1])][getIndex(s[0])] = 0;
    }
    matrix_pow(&a, n - 1, &a);
    long long sum = 0;
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) sum += (long long)a.v[i][j];
    printf("%I64u\n", sum % 1000000007ll);
  }
  return 0;
}
