#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
struct Size {
  int a;
  int b;
  Size() : a(0), b(0) {}
  Size(int a, int b) : a(a), b(b) {}
};
class Macierz {
 private:
  vector<vector<long long> > v;

 public:
  Macierz() {}
  Macierz(int a, int b) : v(a, vector<long long>(b)) {}
  Macierz(int a, int b, long long x) : v(a, vector<long long>(b, x)) {}
  Size size() const {
    if (v.size() == 0) return Size(0, 0);
    return Size(v.size(), v[0].size());
  }
  Macierz operator*(Macierz& b) const {
    Macierz m(v.size(), b[0].size());
    for (int i = 0; i < m.size().a; ++i) {
      for (int j = 0; j < m.size().b; ++j) {
        long long sum = 0;
        for (int k = 0; k < v[0].size(); ++k)
          sum = (sum + (v[i][k] * b[k][j]) % MOD) % MOD;
        m[i][j] = sum;
      }
    }
    return m;
  }
  vector<long long>& operator[](unsigned i) { return v[i]; }
};
Macierz pow(Macierz& m, long long r) {
  if (r == 0) {
    Macierz p(m.size().a, m.size().b, 0);
    for (int i = 0; i < p.size().a; ++i) p[i][i] = 1;
    return p;
  }
  if (r == 1)
    return m;
  else if (r % 2 == 0) {
    Macierz p = pow(m, r / 2);
    return p * p;
  } else {
    return pow(m, r - 1) * m;
  }
}
int Convert(char c) {
  if (c <= 'Z')
    c = c - 'A' + 26;
  else
    c = c - 'a';
  return c;
}
int main() {
  long long n;
  int m;
  int k;
  scanf("%I64d %d %d", &n, &m, &k);
  Macierz macierz(m, m, 1);
  for (int i = 0; i < k; ++i) {
    char a, b;
    scanf("\n%c%c", &a, &b);
    a = Convert(a);
    b = Convert(b);
    macierz[a][b] = 0;
  }
  macierz = pow(macierz, n - 1);
  long long res = 0;
  for (int i = 0; i < macierz.size().a; ++i) {
    for (int j = 0; j < macierz.size().b; ++j)
      res = (res + macierz[i][j]) % MOD;
  }
  printf("%I64d", res);
  return 0;
}
