#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int maxn = 500 + 10;
mt19937_64 rng((unsigned long long)new char);
int matrixRemainder = 1e9 + 7;
struct matrix {
  int row, col;
  vector<vector<long long>> num;
  matrix(int row, int col, long long defaultValue = 0) {
    this->num = std::vector<std::vector<long long>>(
        row, std::vector<long long>(col, defaultValue));
    this->row = row, this->col = col;
  }
  matrix(vector<vector<long long>> num) {
    this->num = num;
    this->row = this->num.size();
    this->col = this->num[0].size();
  }
  matrix operator*(matrix &another) {
    if (this->col != another.row) {
      printf("Wrong size: %d*%d X %d*%d\n", this->row, this->col, another.row,
             another.col);
      throw "Wrong size";
    }
    matrix newone(this->row, another.col);
    for (int r = 0; r < newone.row; r++)
      for (int c = 0; c < newone.col; c++) {
        for (int k = 0; k < this->col; k++) {
          newone.num[r][c] += this->num[r][k] * another.num[k][c];
          newone.num[r][c] %= matrixRemainder;
        }
      }
    return newone;
  }
  matrix operator^(long long x) {
    if (this->row != this->col)
      throw "matrix has different rows and columns!\n";
    if (x == 0) {
      return standard(this->row);
    } else if (x == 1)
      return *this;
    else {
      matrix halfpower = (*this) ^ (x / 2);
      if (x % 2 == 0)
        return halfpower * halfpower;
      else
        return halfpower * halfpower * (*this);
    }
  }
  matrix operator+(matrix &ano) {
    if (row != ano.row || col != ano.col)
      throw "two matrix's sizes unsuitable.\n";
    matrix tmp = *this;
    for (int i = (0); i < (row); ++i)
      for (int j = (0); j < (col); ++j) {
        tmp.num[i][j] += ano.num[i][j], tmp.num[i][j] %= matrixRemainder;
      }
    return tmp;
  }
  matrix operator-(matrix &ano) {
    if (row != ano.row || col != ano.col)
      throw "two matrix's sizes unsuitable.\n";
    matrix tmp = *this;
    for (int i = (0); i < (row); ++i)
      for (int j = (0); j < (col); ++j) {
        tmp.num[i][j] -= ano.num[i][j],
            tmp.num[i][j] = (tmp.num[i][j] + matrixRemainder) % matrixRemainder;
      }
    return tmp;
  }
  matrix standard(int n) {
    matrix tmp(n, n);
    for (int t = (0); t < (n); ++t) tmp.num[t][t] = 1;
    return tmp;
  }
};
long long n;
int m, k;
bool a[52][52];
inline int tr(char c) {
  if (islower(c)) return c - 'a';
  return c - 'A' + 26;
}
int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int t = (0); t < (k); ++t) {
    char x, y;
    cin >> x >> y;
    a[tr(x)][tr(y)] = 1;
  }
  matrix A(m, m);
  for (int i = (0); i < (m); ++i)
    for (int j = (0); j < (m); ++j) A.num[i][j] = !a[i][j];
  matrix B(m, 1, 1);
  B = (A ^ (n - 1)) * B;
  long long ans = 0;
  for (int t = (0); t < (m); ++t) ans = (ans + B.num[t][0]) % mod;
  cout << ans;
}
