#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long mod = 1000000007;
vector<vector<int> > operator*(vector<vector<int> > a, vector<vector<int> > b) {
  vector<vector<int> > c(m + 1);
  for (int i = 0; i < c.size(); i++) c[i].resize(m + 1);
  for (int i = 0; i < m + 1; i++)
    for (int j = 0; j < m + 1; j++)
      for (int k = 0; k < m + 1; k++, c[i][j] %= mod)
        c[i][j] += (a[i][k] * 1ll * b[k][j]) % mod;
  return c;
}
vector<vector<int> > bpow(vector<vector<int> > a, long long st) {
  if (st == 1) return a;
  if (st & 1) return a * bpow(a, st - 1);
  return bpow(a * a, st / 2);
}
int getNum(char cc) {
  if (cc <= 'Z') return cc - 'A' + 27;
  return cc - 'a' + 1;
}
int main() {
  vector<vector<int> > a;
  cin >> n >> m >> k;
  a.resize(m + 1);
  for (int i = 0; i <= m; i++) a[i].resize(m + 1, i > 0);
  for (int i = 0; i < k; i++) {
    string u;
    cin >> u;
    a[getNum(u[1])][getNum(u[0])] = 0;
  }
  a = bpow(a, n);
  long long ans = 0;
  for (int i = 1; i < m + 1; i++, ans %= mod) ans += a[i][0];
  cout << ans;
  return 0;
}
