#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long int INF = 2e10;
const double EPS = 1e-6;
const double pi = 3.14159265358979;
vector<vector<long long> > one(int n, int m) {
  vector<vector<long long> > res;
  res.resize(n);
  for (int i = 0; i < n; i++) {
    res[i].resize(m);
    res[i][i] = 1;
  }
  return res;
}
vector<vector<long long> > mul(const vector<vector<long long> > &a,
                               const vector<vector<long long> > &b, int ss) {
  vector<vector<long long> > res;
  int sz1 = ss, sz2 = ss, ks = ss;
  res.resize(sz1);
  for (int i = 0; i < sz1; i++) res[i].resize(sz2);
  for (int i = 0; i < res.size(); i++) {
    for (int j = 0; j < res[0].size(); j++) {
      for (int k = 0; k < ks; k++) {
        res[i][j] += (a[i][k] * 1ll * b[k][j]) % MOD;
        res[i][j] %= MOD;
      }
    }
  }
  return res;
}
vector<vector<long long> > exp(vector<vector<long long> > a, long long int n,
                               long long int ss) {
  vector<vector<long long> > res = one(a.size(), a[0].size());
  while (n) {
    if (n & 1) res = mul(res, a, ss);
    a = mul(a, a, ss);
    n >>= 1;
  }
  return res;
}
void out(const vector<vector<long long> > &a) {
  for (int i = 0; i < a.size(); i++, cout << "\n")
    for (int j = 0; j < a[0].size(); j++) cout << a[i][j] << " ";
}
int toint(char a) {
  if (isupper(a)) {
    return a - 'A' + 26;
  }
  return (a - 'a');
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  long long int n, m, k;
  char aa, b;
  cin >> n >> m >> k;
  vector<vector<long long> > a;
  a.resize(m);
  for (int i = 0; i < m; i++) {
    a[i].resize(m);
    for (int j = 0; j < m; j++) a[i][j] = 1;
  }
  for (int i = 0; i < k; i++) {
    cin >> aa >> b;
    int x = toint(aa), y = toint(b);
    a[x][y] = 0;
  }
  a = exp(a, n - 1, m);
  long long int ans = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      ans += a[i][j];
      ans %= MOD;
    }
  }
  cout << ans;
  return 0;
}
