#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1, typename... Tail>
T amin(T& a, T1 b, Tail... c) {
  if (b < a) a = b;
  if constexpr (sizeof...(c) != 0) {
    amin(a, c...);
  }
  return a;
}
template <typename T, typename T1, typename... Tail>
T amax(T& a, T1 b, Tail... c) {
  if (b > a) a = b;
  if constexpr (sizeof...(c) != 0) {
    amax(a, c...);
  }
  return a;
}
template <typename T>
T mod_inv_in_range(T a, T m) {
  T x = a, y = m;
  T vx = 1, vy = 0;
  while (x) {
    T k = y / x;
    y %= x;
    vy -= k * vx;
    swap(x, y);
    swap(vx, vy);
  }
  assert(y == 1);
  return vy < 0 ? m + vy : vy;
}
template <typename T>
T mod_inv(T a, T m) {
  a %= m;
  a = a < 0 ? a + m : a;
  return mod_inv_in_range(a, m);
}
template <int MOD_>
struct modnum {
  static constexpr int MOD = MOD_;
  static_assert(MOD_ > 0, "MOD must be positive");

 private:
  int v;

 public:
  modnum() : v(0) {}
  modnum(int64_t v_) : v(int(v_ % MOD)) {
    if (v < 0) v += MOD;
  }
  explicit operator int() const { return v; }
  friend std::ostream& operator<<(std::ostream& out, const modnum& n) {
    return out << int(n);
  }
  friend std::istream& operator>>(std::istream& in, modnum& n) {
    int64_t v_;
    in >> v_;
    n = modnum(v_);
    return in;
  }
  friend bool operator==(const modnum& a, const modnum& b) {
    return a.v == b.v;
  }
  friend bool operator!=(const modnum& a, const modnum& b) {
    return a.v != b.v;
  }
  modnum inv() const {
    modnum res;
    res.v = mod_inv_in_range(v, MOD);
    return res;
  }
  friend modnum inv(const modnum& m) { return m.inv(); }
  modnum neg() const {
    modnum res;
    res.v = v ? MOD - v : 0;
    return res;
  }
  friend modnum neg(const modnum& m) { return m.neg(); }
  modnum operator-() const { return neg(); }
  modnum operator+() const { return modnum(*this); }
  modnum& operator++() {
    v++;
    if (v == MOD) v = 0;
    return *this;
  }
  modnum& operator--() {
    if (v == 0) v = MOD;
    v--;
    return *this;
  }
  modnum& operator+=(const modnum& o) {
    v -= MOD - o.v;
    v = (v < 0) ? v + MOD : v;
    return *this;
  }
  modnum& operator-=(const modnum& o) {
    v -= o.v;
    v = (v < 0) ? v + MOD : v;
    return *this;
  }
  modnum& operator*=(const modnum& o) {
    v = int(int64_t(v) * int64_t(o.v) % MOD);
    return *this;
  }
  modnum& operator/=(const modnum& o) { return *this *= o.inv(); }
  friend modnum operator++(modnum& a, int) {
    modnum r = a;
    ++a;
    return r;
  }
  friend modnum operator--(modnum& a, int) {
    modnum r = a;
    --a;
    return r;
  }
  friend modnum operator+(const modnum& a, const modnum& b) {
    return modnum(a) += b;
  }
  friend modnum operator-(const modnum& a, const modnum& b) {
    return modnum(a) -= b;
  }
  friend modnum operator*(const modnum& a, const modnum& b) {
    return modnum(a) *= b;
  }
  friend modnum operator/(const modnum& a, const modnum& b) {
    return modnum(a) /= b;
  }
  friend string to_string(const modnum& b) { return to_string(b.v); }
};
const int64_t MOD_ = 1000000007;
using Mint = modnum<MOD_>;
template <typename T>
struct matrix {
  int N, M;
  std::vector<T> data;
  matrix(int _N, int _M, T value = T{}) : N(_N), M(_M), data(N * M, value) {}
  typename std::vector<T>::iterator operator[](int i) {
    return data.begin() + i * M;
  }
  typename std::vector<T>::const_iterator operator[](int i) const {
    return data.begin() + i * M;
  }
  friend void init(matrix<T>& a, const vector<vector<T>>& b) {
    assert(a.N == int(b.size()) && a.M == int(b[0].size()));
    for (int i = 0; i < a.N; i++)
      for (int j = 0; j < a.M; j++) a[i][j] = b[i][j];
  }
  friend matrix<T> operator*(const matrix<T>& a, const matrix<T>& b) {
    assert(a.M == b.N);
    matrix<T> res(a.N, b.M);
    for (int i = 0; i < a.N; i++)
      for (int k = 0; k < a.M; k++)
        for (int j = 0; j < b.M; j++) res[i][j] += a[i][k] * b[k][j];
    return res;
  }
  friend matrix<T> operator+(const matrix<T>& a, const matrix<T>& b) {
    assert(a.N == b.N && a.M == b.M);
    matrix<T> res(a.N, a.M);
    for (int i = 0; i < a.N; i++)
      for (int k = 0; k < a.M; k++) res[i][k] = a[i][k] + b[i][k];
    return res;
  }
  friend matrix<T> operator-(const matrix<T>& a, const matrix<T>& b) {
    assert(a.N == b.N && a.M == b.M);
    matrix<T> res(a.N, a.M);
    for (int i = 0; i < a.N; i++)
      for (int k = 0; k < a.M; k++) res[i][k] = a[i][k] - b[i][k];
    return res;
  }
  friend void row_reduce(matrix<T>& m) {
    int rank = 0;
    for (int j = 0; j < m.M && rank < m.N; j++) {
      for (int i = rank; i < m.N; i++) {
        if (m[i][j] != 0) {
          swap_ranges(m[rank], m[rank] + m.M, m[i]);
          break;
        }
      }
      if (m[rank][j] == 0) continue;
      T inv = 1 / m[rank][j];
      for (int k = j; k < m.M; k++) m[rank][k] *= inv;
      for (int i = 0; i < m.N; i++) {
        if (i != rank) {
          T c = m[i][j];
          for (int k = j; k < m.M; k++) m[i][k] -= c * m[rank][k];
        }
      }
      rank++;
    }
    m.N = rank;
    m.data.resize(m.N * m.M);
  }
  friend std::ostream& operator<<(std::ostream& os, const matrix<T>& m) {
    for (int i = 0; i < m.N; i++) {
      os << (i ? i < m.N - 1 ? "\u2503" : "\u2517" : "\n\u250F");
      for (int j = 0; j < m.M; j++) os << std::setw(12) << m[i][j];
      os << "  " << (i ? i < m.N - 1 ? "\u2503" : "\u251B" : "\u2512") << "\n";
    }
    return os;
  }
};
using mtr = matrix<Mint>;
const int64_t maxN = 2e5 + 5;
void preSolve(int& testcases) {}
void solve() {
  int64_t n, m, k;
  cin >> n >> m >> k;
  mtr dp(m, m, 1);
  for (int i = 0; i < k; i++) {
    char ch1, ch2;
    cin >> ch1 >> ch2;
    int a1, a2;
    if (ch1 >= 'a' && ch1 <= 'z')
      a1 = ch1 - 'a';
    else
      a1 = ch1 - 'A' + 26;
    if (ch2 >= 'a' && ch2 <= 'z')
      a2 = ch2 - 'a';
    else
      a2 = ch2 - 'A' + 26;
    dp[a1][a2] = 0;
  }
  mtr ide(m, m, 0);
  for (int i = 0; i < m; i++) ide[i][i] = 1;
  int64_t p = n - 1;
  while (p > 0) {
    if (p & 1) ide = ide * dp;
    p >>= 1;
    dp = dp * dp;
  }
  mtr base(m, 1, 1);
  mtr res = ide * base;
  Mint ans = 0;
  for (int i = 0; i < m; i++) {
    ans += res[i][0];
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int testcases = 1;
  preSolve(testcases);
  for (int caseno = 1; caseno <= testcases; ++caseno) {
    solve();
  }
  return 0;
}
