#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
typedef struct {
  long long a[55][55];
  int l;
} Martix;
void E(Martix &A) {
  memset(A.a, 0, sizeof(A.a));
  for (int i = 0; i < A.l; ++i) {
    A.a[i][i] = 1;
  }
}
void setOne(Martix &A) {
  for (int i = 0; i < A.l; ++i) {
    for (int j = 1; j < A.l; ++j) {
      A.a[i][j] = 1;
    }
  }
}
Martix mul(Martix A, Martix B) {
  int l = A.l;
  Martix ans;
  ans.l = l;
  for (int i = 0; i < l; ++i) {
    for (int j = 0; j < l; ++j) {
      long long sum = 0;
      for (int k = 0; k < l; ++k) {
        sum = (sum + A.a[i][k] * B.a[k][j]) % mod;
      }
      ans.a[i][j] = sum;
    }
  }
  return ans;
}
void print(Martix A) {
  for (int i = 0; i < A.l; ++i) {
    for (int j = 0; j < A.l; ++j) {
      printf("%I64d   ", A.a[i][j]);
    }
    printf("\n");
  }
}
int hash(char c) {
  if (c >= 'A' && c <= 'Z') {
    return c - 'A' + 27;
  }
  return c - 'a' + 1;
}
int main() {
  long long n;
  int m, k;
  char buf[5];
  scanf("%I64d%d%d", &n, &m, &k);
  ++m;
  Martix mar;
  mar.l = m;
  setOne(mar);
  for (int i = 1; i <= k; ++i) {
    scanf("%s", buf);
    int x = hash(buf[0]);
    int y = hash(buf[1]);
    mar.a[x][y] = 0;
  }
  Martix ans;
  ans.l = m;
  E(ans);
  for (; n; n >>= 1) {
    if (n & 1) {
      ans = mul(ans, mar);
    }
    mar = mul(mar, mar);
  }
  long long result = 0;
  for (int i = 0; i < m; ++i) {
    result = (result + ans.a[0][i]) % mod;
  }
  printf("%I64d\n", result);
  return 0;
}
