#include <bits/stdc++.h>
using namespace std;
int ms;
struct mat {
  long long m[54][54];
  mat(){};
  void unify() {
    memset(m, 0, sizeof(m));
    for (int i = 0; i < ms; i++) {
      for (int j = 0; j < ms; j++) {
        if (i == j) m[i][j] = 1;
      }
    }
  }
  void print() {
    for (int i = 0; i < ms; i++) {
      for (int j = 0; j < ms; j++) {
        cout << m[i][j] << " - ";
      }
      puts("");
    }
    puts("");
  }
  void nullify() { memset(m, 0, sizeof(m)); }
};
mat b;
mat operator*(mat a, mat b) {
  mat c;
  for (int i = 0; i < ms; i++) {
    for (int j = 0; j < ms; j++) {
      c.m[i][j] = 0;
      for (int k = 0; k < ms; k++) {
        c.m[i][j] += (a.m[i][k] * b.m[k][j]) % 1000000007LL;
        c.m[i][j] %= 1000000007LL;
      }
    }
  }
  return c;
}
bool vis[54][54];
void gen_base(int m) {
  int i, j;
  ms = m;
  b.nullify();
  for (i = 0; i <= m - 1; i++) {
    for (j = 0; j <= m - 1; j++) {
      if (!vis[i][j]) b.m[i][j] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long n, m, i, j, k;
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    char s[5];
    cin >> s;
    int ia, ib;
    if (isupper(s[0]))
      ia = (s[0] - 'A' + 26);
    else
      ia = (s[0] - 'a');
    if (isupper(s[1]))
      ib = (s[1] - 'A' + 26);
    else
      ib = (s[1] - 'a');
    vis[ia][ib] = 1;
  }
  gen_base(m);
  n--;
  if (n == 0) {
    cout << m << endl;
    return 0;
  }
  mat B = b;
  mat ret;
  ret.unify();
  while (n) {
    if (n & 1) ret = (ret * B);
    B = (B * B);
    n >>= 1;
  }
  long long ans = 0LL;
  for (i = 0; i <= m - 1; i++) {
    for (j = 0; j <= m - 1; j++) {
      ans = (ans + ret.m[i][j]) % 1000000007LL;
    }
  }
  cout << ans << endl;
  return 0;
}
