#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
struct mat {
  long long a[100][100], n1;
  mat(int x, int y) {
    n1 = x;
    for (int i = 1; i <= n1; i++) {
      for (int j = 1; j <= n1; j++) {
        a[i][j] = y;
      }
    }
  }
  inline mat multi(mat o) {
    mat t(n1, 0);
    for (int i = 1; i <= n1; i++) {
      for (int j = 1; j <= n1; j++) {
        for (int k = 1; k <= n1; k++) {
          t.a[i][j] += (a[i][k] * o.a[k][j]);
          t.a[i][j] %= mod;
        }
      }
    }
    return t;
  }
  inline void prin() {
    cout << n1 << endl;
    for (int i = 1; i <= n1; i++) {
      for (int j = 1; j <= n1; j++) {
        cout << a[i][j] << ' ';
      }
      cout << endl;
    }
  }
};
string str;
inline int gett(char x) {
  if (x > 'Z') return x - 'a' + 1;
  return 26 + (x - 'A' + 1);
}
mat a1(90, 1), a2(90, 1);
void exp(long long x) {
  if (x == 1) return;
  exp(x / 2);
  a1 = a1.multi(a1);
  if (x & 1) a1 = a1.multi(a2);
}
void exp2(long long x) {
  a1.prin();
  for (int i = 1; i < x; i++) {
    cout << i + 1 << endl;
    a1 = a1.multi(a2);
    a1.prin();
  }
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  a1.n1 = m;
  a2.n1 = m;
  for (int i = 1; i <= k; i++) {
    cin >> str;
    a1.a[gett(str[0])][gett(str[1])] = a2.a[gett(str[0])][gett(str[1])] = 0;
  }
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  exp(n - 1);
  long long summ = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      summ += a1.a[i][j];
      summ %= mod;
    }
  }
  cout << summ << endl;
  return 0;
}
