#include <bits/stdc++.h>
using namespace std;
class matris {
 public:
  long long int n, a[100][100];
  matris() { memset(a, 0, sizeof a); }
  matris(int t) { fill(a[0], a[95] + 95, 1LL); }
} birim, A(1);
matris operator*(matris A, matris B) {
  matris temp;
  temp.n = A.n;
  for (int i = 1; i <= temp.n; i++)
    for (int j = 1; j <= temp.n; j++)
      for (int k = 1; k <= temp.n; k++)
        temp.a[i][j] = (temp.a[i][j] + A.a[i][k] * B.a[k][j]) % 1000000007LL;
  return temp;
}
matris operator^(matris A, long long int k) {
  if (!k) return birim;
  matris t = A ^ (k / 2);
  if (k & 1) return t * t * A;
  return t * t;
}
int main() {
  long long int n, m, k, i, j;
  char a, b;
  cin >> n >> m >> k;
  A.n = m + 1;
  birim.n = m + 1;
  for (int i = 1; i <= m + 1; i++) A.a[i][1] = 0, birim.a[i][i] = 1;
  while (k--) {
    cin >> a >> b;
    if ('a' <= a)
      i = a - 'a' + 2;
    else
      i = a - 'A' + 28;
    if ('a' <= b)
      j = b - 'a' + 2;
    else
      j = b - 'A' + 28;
    A.a[i][j] = 0;
  }
  A = A ^ n;
  long long int res = 0;
  for (int i = 1; i <= m + 1; i++) res = (res + A.a[1][i]) % 1000000007LL;
  cout << res << endl;
}
