#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007, N = 100000, M = 1000;
long long n, m, k;
vector<vector<long long> > a(60, vector<long long>(60, 1));
vector<long long> ans(60, 1);
vector<long long> add(vector<long long> y) {
  vector<long long> res(m + 1, 0);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      res[i] += a[i][j] * 1ll * y[j];
      res[i] %= INF;
    }
  }
  return res;
}
vector<vector<long long> > kol() {
  vector<vector<long long> > n(60, vector<long long>(60, 0));
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      for (int l = 1; l <= m; l++) {
        n[i][j] += a[i][l] * 1ll * a[l][j];
        n[i][j] %= INF;
      }
    }
  }
  return n;
}
vector<long long> res(60, 1);
void binpow() {
  while (n) {
    if (n % 2 == 1) res = add(res);
    a = kol();
    n /= 2;
  }
}
int in(char c) {
  if (c >= 'a' && c <= 'z') {
    return c - 'a' + 1;
  } else
    return c - 'A' + 27;
}
long long sum = 0;
void rec(int v = 0, int now = -1) {
  if (v > n) {
    sum++;
    return;
  }
  for (int i = 1; i <= m; i++) {
    if (now == -1 || a[now][i]) rec(v + 1, i);
  }
}
int main() {
  cin >> n >> m >> k;
  n--;
  for (int i = 1; i <= k; i++) {
    string s;
    cin >> s;
    a[in(s[0])][in(s[1])] = 0;
  }
  sum = 0;
  binpow();
  for (int i = 1; i <= m; i++) {
    sum += res[i];
    sum %= INF;
  }
  cout << sum;
  return 0;
}
