#include <bits/stdc++.h>
using namespace std;
const long long int order = 53;
vector<vector<long long int> > mul(vector<vector<long long int> > A,
                                   vector<vector<long long int> > B) {
  long long int i, j, k;
  vector<vector<long long int> > C(order + 1, vector<long long int>(order + 1));
  for (i = 0; i < order; i++) {
    for (j = 0; j < order; j++) {
      for (k = 0; k < order; k++) {
        C[i][j] = (C[i][j] % 1000000007 +
                   (A[i][k] % 1000000007 * B[k][j] % 1000000007) % 1000000007 +
                   1000000007) %
                  1000000007;
      }
    }
  }
  return C;
}
vector<vector<long long int> > powerm(vector<vector<long long int> > A,
                                      long long int n) {
  if (n == 1) return A;
  if (n % 2 == 1) return mul(A, powerm(A, n - 1));
  vector<vector<long long int> > res = powerm(A, n / 2);
  return mul(res, res);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<vector<long long int> > T(order + 1, vector<long long int>(order + 1));
  long long int n, m, k;
  cin >> n >> m >> k;
  string s1;
  ;
  long long int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < m; j++) {
      T[i][j] = 1;
    }
  }
  for (i = 0; i < k; i++) {
    cin >> s1;
    char x, y;
    x = s1[0];
    y = s1[1];
    long long int i1, i2;
    if (x >= 'a' && x <= 'z')
      i1 = x - 'a';
    else
      i1 = x - 'A' + 26ll;
    if (y >= 'a' && y <= 'z')
      i2 = y - 'a';
    else
      i2 = y - 'A' + 26ll;
    T[i1][i2] = 0;
  }
  vector<vector<long long int> > TR(order + 1,
                                    vector<long long int>(order + 1));
  long long int ans = 0;
  if (n > 1) {
    TR = powerm(T, n - 1);
    for (i = 0; i < m; i++) {
      for (j = 0; j < m; j++) {
        ans = (ans + TR[i][j]) % 1000000007;
      }
    }
  } else {
    ans = m % 1000000007;
  }
  cout << ans;
}
