#include <bits/stdc++.h>
using namespace std;
int M = 1e9 + 7;
void copym(vector<vector<long long> > &a, vector<vector<long long> > &b) {
  for (int i = 0; i < 52; i++)
    for (int j = 0; j < 52; j++) a[i][j] = b[i][j];
}
void mul(vector<vector<long long> > &a, vector<vector<long long> > &b,
         vector<vector<long long> > &c) {
  for (int i = 0; i < 52; i++) {
    for (int j = 0; j < 52; j++) {
      a[i][j] = 0;
      for (int k = 0; k < 52; k++)
        a[i][j] = (a[i][j] + (b[i][k] * c[k][j]) % M) % M;
    }
  }
}
vector<vector<long long> > fn(long long n, int m, vector<string> arr) {
  vector<vector<long long> > ans(52, vector<long long>(52, 0)),
      a(52, vector<long long>(52, 0)), temp(52, vector<long long>(52, 1)),
      temp2(52, vector<long long>(52, 1));
  for (int i = 0; i < 52; i++) ans[i][i] = 1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) a[i][j] = 1;
  for (int i = 0; i < arr.size(); i++) {
    int x, y;
    if (arr[i][0] >= 'a' && arr[i][0] <= 'z')
      x = arr[i][0] - 'a';
    else
      x = 26 + arr[i][0] - 'A';
    if (arr[i][1] >= 'a' && arr[i][1] <= 'z')
      y = arr[i][1] - 'a';
    else
      y = 26 + arr[i][1] - 'A';
    a[y][x] = 0;
  }
  while (n > 0) {
    if (n & 1) {
      copym(temp, ans);
      copym(temp2, a);
      mul(ans, temp, temp2);
    }
    copym(temp, a);
    copym(temp2, a);
    mul(a, temp, temp2);
    n /= 2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<string> arr(k);
  for (int i = 0; i < k; i++) cin >> arr[i];
  vector<vector<long long> > ans = fn(n - 1, m, arr);
  long long prem(0);
  for (int i = 0; i < 52; i++)
    for (int j = 0; j < 52; j++) prem = (prem + ans[i][j]) % M;
  if (n == 1)
    cout << m;
  else
    cout << prem;
  return 0;
}
