#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;
long long n, m, k;
struct matrix {
  int row, col;
  long long** mt;
  matrix(int r, int c) {
    row = r;
    col = c;
    mt = new long long*[r];
    for (int i = 0; i < row; i++) {
      mt[i] = new long long[col];
      for (int j = 0; j < col; j++) mt[i][j] = 0;
    }
  }
  matrix() {}
  matrix operator*(matrix other) {
    matrix ret = matrix(row, other.col);
    for (int i = 0; i < ret.row; i++) {
      for (int j = 0; j < ret.col; j++) {
        for (int k = 0; k < other.row; k++)
          ret.mt[i][j] =
              (ret.mt[i][j] + (this->mt[i][k] * other.mt[k][j]) % mod) % mod;
      }
    }
    return ret;
  }
  void printMatrix() {
    for (int i = 0; i < row; i++) {
      for (int j = 0; j < col; j++) cout << mt[i][j] << " ";
      cout << "\n";
    }
  }
};
matrix identity(int d) {
  matrix ret = matrix(d, d);
  for (int i = 0; i < d; i++) ret.mt[i][i] = 1;
  return ret;
}
matrix iden;
matrix binPow(matrix b, long long ex) {
  if (ex == 0) return iden;
  if (ex == 1) return b;
  matrix aux = binPow(b, ex / 2);
  aux = aux * aux;
  if (ex % 2 == 1) aux = aux * b;
  return aux;
}
int adj[52][52];
string str;
int indexx(char c) {
  if (c - 'a' >= 0 && c - 'a' < 26) return c - 'a';
  return c - 'A' + 26;
}
void solve() {
  cin >> n >> m >> k;
  iden = identity(m);
  for (int i = 0; i < k; i++) {
    cin >> str;
    int f = indexx(str[0]);
    int s = indexx(str[1]);
    adj[s][f] = 1;
  }
  matrix elev = matrix(m, m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++)
      if (adj[i][j] == 0) elev.mt[i][j] = 1;
  }
  matrix vm = matrix(m, 1);
  for (int i = 0; i < m; i++) vm.mt[i][0] = 1;
  matrix k = binPow(elev, n - 1);
  matrix sol = k * vm;
  long long answ = 0;
  for (int i = 0; i < m; i++) answ = (answ + sol.mt[i][0]) % mod;
  cout << answ << "\n";
}
void fastIO() {
  cin.sync_with_stdio(false);
  cin.tie(0);
}
void IO() {
  if (fopen("d:\\lmo.in", "r") != NULL) {
    freopen("d:\\lmo.in", "r", stdin);
  } else if (fopen("/media/luismo/Pablo's Destruction/lmo.in", "r") != NULL) {
    freopen("/media/luismo/Pablo's Destruction/lmo.in", "r", stdin);
  }
}
int main() {
  IO();
  fastIO();
  solve();
}
