#include <bits/stdc++.h>
using namespace std;
int id(char c) {
  if (c >= 'a' && c <= 'z') return c - 'a';
  return c - 'A' + 26;
}
const long long MOD = 1e9 + 7;
const long long MOD2 = MOD * MOD;
template <typename T>
struct Matrix {
  int r, c;
  vector<vector<T>> m;
  Matrix() {}
  Matrix(int _r, int _c) : r(_r), c(_c) {
    m.resize(r);
    for (int i = 0; i < r; ++i) {
      m[i].resize(c);
    }
  }
  Matrix operator*(const Matrix& b) {
    Matrix a = *this;
    Matrix c(a.r, b.c);
    for (int i = 0; i < a.r; ++i) {
      for (int k = 0; k < b.r; ++k) {
        for (int j = 0; j < b.c; ++j) {
          T p = (a.m[i][k] * b.m[k][j]);
          c.m[i][j] += p;
          if (c.m[i][j] >= MOD2) c.m[i][j] -= MOD2;
        }
      }
    }
    for (int i = 0; i < a.r; ++i) {
      for (int j = 0; j < b.c; ++j) {
        c.m[i][j] %= MOD;
      }
    }
    return c;
  }
  void id() {
    assert(r == c);
    for (int i = 0; i < r; ++i) {
      for (int j = 0; j < r; ++j) {
        m[i][j] = (i == j);
      }
    }
  }
};
Matrix<long long> fexp(Matrix<long long> b, long long e) {
  Matrix<long long> r(b.r, b.r);
  r.id();
  while (e) {
    if (e & 1) r = r * b;
    b = b * b;
    e >>= 1;
  }
  return r;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  long long n, M, k;
  cin >> n >> M >> k;
  Matrix<long long> T(M, M);
  Matrix<long long> F(M, 1);
  for (int i = 0; i < M; ++i) {
    F.m[i][0] = 1;
    for (int j = 0; j < M; ++j) {
      T.m[i][j] = 1;
    }
  }
  for (int i = 0; i < k; ++i) {
    string s;
    cin >> s;
    int u = id(s[0]), v = id(s[1]);
    T.m[u][v] = 0;
  }
  T = fexp(T, n - 1) * F;
  long long ans = 0;
  for (int i = 0; i < M; ++i) {
    ans += T.m[i][0];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
