#include <bits/stdc++.h>
using namespace std;
const int max_m = 55;
const int inv = 1000000007;
long long n;
int m, k;
long long a[max_m][max_m], b[max_m][max_m], c[max_m][max_m], d[max_m][max_m];
void mult() {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      a[i][j] = 0;
      for (int k = 0; k < m; k++) {
        a[i][j] += (c[i][k] * b[k][j]) % inv;
        a[i][j] %= inv;
      }
    }
}
void exp(long long no) {
  if (no == 1) return;
  exp(no / 2);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      c[i][j] = a[i][j];
      b[i][j] = a[i][j];
    }
  mult();
  if (no % 2 == 1) {
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) {
        c[i][j] = a[i][j];
        b[i][j] = d[i][j];
      }
    mult();
  }
}
int main() {
  cin >> n;
  scanf("%d%d", &m, &k);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = 1;
  char c[2];
  for (int i = 0; i < k; i++) {
    scanf("%s", c);
    int a1 = c[0];
    int a2 = c[1];
    if (a1 >= 97)
      a1 -= 97;
    else
      a1 -= 39;
    if (a2 >= 97)
      a2 -= 97;
    else
      a2 -= 39;
    a[a1][a2] = 0;
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      b[i][j] = a[i][j];
      d[i][j] = a[i][j];
    }
  long long res = 0;
  if (n == 1) res = m;
  if (n > 1) {
    exp(n - 1);
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) {
        res += a[i][j];
        res %= inv;
      }
  }
  cout << res;
  return 0;
}
