#include <bits/stdc++.h>
using namespace std;
long long n, m, ans[60][60], a[60][60], c[60][60], t, res;
char x, y;
int main() {
  cin >> n >> m >> t;
  for (long long i = 1; i <= m; i++) {
    ans[i][i] = 1;
    for (long long j = 1; j <= m; j++) a[i][j] = 1;
  }
  for (long long i = 1; i <= t; i++) {
    cin >> x >> y;
    if (x <= 90)
      x -= 38;
    else
      x -= 96;
    if (y <= 90)
      y -= 38;
    else
      y -= 96;
    a[y][x] = 0;
  }
  n--;
  while (n) {
    if (n & 1) {
      for (long long i = 1; i <= m; i++)
        for (long long j = 1; j <= m; j++) {
          c[i][j] = 0;
          for (long long k = 1; k <= m; k++)
            c[i][j] += ans[i][k] * a[k][j], c[i][j] %= 1000000007;
        }
      for (long long i = 1; i <= m; i++)
        for (long long j = 1; j <= m; j++) ans[i][j] = c[i][j];
    }
    for (long long i = 1; i <= m; i++)
      for (long long j = 1; j <= m; j++) {
        c[i][j] = 0;
        for (long long k = 1; k <= m; k++)
          c[i][j] += a[i][k] * a[k][j], c[i][j] %= 1000000007;
      }
    for (long long i = 1; i <= m; i++)
      for (long long j = 1; j <= m; j++) a[i][j] = c[i][j];
    n /= 2;
  }
  for (long long i = 1; i <= m; i++)
    for (long long j = 1; j <= m; j++) res += ans[i][j], res %= 1000000007;
  cout << res;
}
