#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592653589793;
const int P = 1e9 + 7;
class mint {
 public:
  static int init_siz;
  static vector<mint> inverse, factorial;
  static int mintP;
  int n = 0;
  static mint exp(mint a, long long e) {
    mint res = 1;
    while (e) {
      if (e & 1) res *= a;
      a *= a;
      e >>= 1;
    }
    return res;
  }
  static void init(int n) {
    init_siz = n;
    inverse.resize(n + 1);
    factorial.resize(n + 1);
    factorial[0] = 1;
    for (int i = 1; i <= n; i++) factorial[i] = factorial[i - 1] * i;
    inverse[n] = exp(factorial[n], mintP - 2);
    for (int i = n - 1; i >= 0; i--) inverse[i] = inverse[i + 1] * (i + 1);
  }
  static mint inv(mint const& a) {
    return (init_siz >= a.n ? inverse[a.n] * (a.n > 1 ? fac(a - 1) : 1)
                            : exp(a, mintP - 2));
  }
  static mint cinv(mint const& a) {
    return (init_siz >= a.n ? inverse[a.n] : exp(fac(a), mintP - 2));
  }
  static mint fac(mint const& a) {
    if (init_siz >= a.n)
      return factorial[a.n];
    else {
      mint out = 1;
      for (int i = 0; i < a.n; i++) out *= (i + 1);
      return out;
    }
  }
  mint(long long val = 0) {
    n = val % mintP;
    if (n < 0) n += mintP;
  }
  mint& operator+=(mint const& b) {
    n += b.n;
    if (n >= mintP) n -= mintP;
    return *this;
  }
  mint& operator-=(mint const& b) {
    n -= b.n;
    if (n < 0) n += mintP;
    return *this;
  }
  mint& operator*=(mint const& b) {
    n = (long long)n * b.n % mintP;
    return *this;
  }
  mint exp(long long e) { return exp(*this, e); }
  mint inv() { return inv(*this); }
  mint& operator/=(mint const& b) { return *this *= inv(b); }
  friend std::ostream& operator<<(std::ostream& os, mint const& a) {
    return os << (a.n < 0 ? a.n + mintP : a.n);
  }
  friend mint operator+(mint a, mint const b) { return a += b; }
  friend mint operator-(mint a, mint const b) { return a -= b; }
  friend mint operator-(mint const a) { return 0 - a; }
  friend mint operator*(mint a, mint const b) { return a *= b; }
  friend mint operator/(mint a, mint const b) { return a /= b; }
  friend bool operator==(mint const& a, mint const& b) { return a.n == b.n; }
  friend bool operator!=(mint const& a, mint const& b) { return a.n != b.n; }
};
int mint::init_siz = 0;
int mint::mintP = P;
vector<mint> mint::factorial, mint::inverse;
const int mx = 52;
void mul(mint a[mx][mx], mint b[mx][mx]) {
  mint res[mx][mx] = {};
  for (int i = 0; i < mx; i++) {
    for (int j = 0; j < mx; j++) {
      for (int k = 0; k < mx; k++) {
        res[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for (int i = 0; i < mx; i++)
    for (int j = 0; j < mx; j++) a[i][j] = res[i][j];
}
long long n;
int m, k;
mint mat[mx][mx] = {};
mint val[mx][mx];
void binmult(long long n) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) val[i][j] = (i == j);
  while (n) {
    if (n & 1) mul(val, mat);
    mul(mat, mat);
    n >>= 1;
  }
}
void solve() {
  cin >> n >> m >> k;
  n--;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) mat[i][j] = 1;
  for (int i = 0; i < k; i++) {
    string k;
    cin >> k;
    int a, b;
    if (k[0] > 'Z')
      a = k[0] - 'a';
    else
      a = 26 + k[0] - 'A';
    if (k[1] > 'Z')
      b = k[1] - 'a';
    else
      b = 26 + k[1] - 'A';
    mat[b][a] = 0;
  }
  binmult(n);
  mint out = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) out += val[i][j];
  cout << out;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  for (int c = 1; c < T + 1; c++) {
    solve();
  }
}
