#include <bits/stdc++.h>
const double eps = 1e-7, PI = 3.1415926;
const long long N = 53, M = 1e9 + 7;
using namespace std;
long long n, q, m, k, x, y, a[N][N], mx = -1, mn = 1e9, sum;
string s, s1, s2;
map<pair<long long, long long>, long long> mp;
vector<long long> vec;
struct Matrix {
  long long a[N][N];
  Matrix() {
    for (long long i = 0; i < N; i++)
      for (long long j = 0; j < N; j++) a[i][j] = 0;
  }
  Matrix operator*(Matrix other) {
    Matrix ret;
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        for (long long k = 0; k < N; k++) {
          ret.a[i][k] += a[i][j] * other.a[j][k];
          ret.a[i][k] %= M;
        }
      }
    }
    return ret;
  }
};
Matrix zero;
Matrix POW(Matrix a, long long b) {
  if (b == 0) return zero;
  Matrix ret = POW(a, b / 2);
  ret = ret * ret;
  if (b % 2) return ret * a;
  return ret;
}
int32_t main() {
  cin >> n >> m >> k;
  Matrix fi;
  for (long long i = 0; i < N; i++) zero.a[i][i] = 1;
  for (long long i = 0; i < k; i++) {
    cin >> s;
    if (s[0] >= 'a' && s[0] <= 'z')
      x = s[0] - 'a';
    else
      x = s[0] - 'A' + 26;
    if (s[1] >= 'a' && s[1] <= 'z')
      y = s[1] - 'a';
    else
      y = s[1] - 'A' + 26;
    fi.a[x][y] = 1;
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      fi.a[i][j] ^= 1;
    }
  }
  fi = POW(fi, n - 1);
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      sum = (sum + fi.a[i][j]) % M;
    }
  }
  cout << sum;
  return 0;
}
