#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
struct Matrix {
  int n, m;
  long long a[105][105];
  Matrix(int x, int y) {
    n = x, m = y;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) a[i][j] = 0;
    }
  }
  void init() {
    for (int i = 1; i <= min(n, m); i++) a[i][i] = 1;
  }
  void print() {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) cout << a[i][j] << " ";
      cout << endl;
    }
    cout << endl;
  }
};
Matrix operator*(Matrix a, Matrix b) {
  Matrix c = Matrix(a.n, b.m);
  for (int i = 1; i <= a.n; i++) {
    for (int j = 1; j <= b.m; j++) {
      for (int k = 1; k <= a.m; k++) {
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % p) % p;
      }
    }
  }
  return c;
}
Matrix qpow(Matrix a, long long b) {
  Matrix res = Matrix(a.n, a.m);
  res.init();
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long n, m, k;
int main() {
  cin >> n >> m >> k;
  Matrix f = Matrix(m, m);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) f.a[i][j] = 1;
  }
  string s;
  int x, y, z;
  while (k--) {
    cin >> s;
    if (s[0] <= 'Z' && s[0] >= 'A')
      x = s[0] - 'A' + 27;
    else
      x = s[0] - 'a' + 1;
    if (s[1] <= 'Z' && s[1] >= 'A')
      y = s[1] - 'A' + 27;
    else
      y = s[1] - 'a' + 1;
    f.a[x][y] &= 0;
  }
  Matrix ans = Matrix(1, m);
  for (int i = 1; i <= m; i++) ans.a[1][i] = 1;
  f = qpow(f, n - 1);
  ans = ans * f;
  long long res = 0;
  for (int i = 1; i <= m; i++) res += ans.a[1][i], res %= p;
  cout << res << endl;
  return 0;
}
