#include <bits/stdc++.h>
using namespace std;
const int MAXR = 60;
const int MODP = 1000000007;
long long n;
int m, k;
struct matrix {
  int w, h;
  matrix() {}
  matrix(int hh, int ww) {
    w = ww;
    h = hh;
  }
  int p[MAXR][MAXR];
};
matrix forb;
matrix operator*(matrix a, matrix b) {
  matrix wyn = matrix(a.h, b.w);
  for (int i = 0; i < (a.h); ++i) {
    for (int j = 0; j < (b.w); ++j) {
      wyn.p[i][j] = 0;
    }
  }
  for (int i = 0; i < (a.h); ++i) {
    for (int j = 0; j < (b.w); ++j) {
      for (int k = 0; k < (a.w); ++k) {
        wyn.p[i][j] =
            ((long long)wyn.p[i][j] + (long long)a.p[i][k] * b.p[k][j]) % MODP;
      }
    }
  }
  return wyn;
}
matrix pot(matrix A, long long n) {
  if (n <= 1) {
    return A;
  }
  if ((n % 2) == 0) {
    matrix t = pot(A, n / 2);
    return t * t;
  } else
    return A * pot(A, n - 1);
}
int dajInt(char c) {
  if ((c >= 'a') && (c <= 'z')) {
    return (int)c - (int)'a';
  } else {
    return int(c) - (int)'A' + 26;
  }
}
int dajSume(matrix a) {
  int wyn = 0;
  for (int i = 0; i < (a.w); ++i) {
    for (int j = 0; j < (a.h); ++j) {
      wyn = (wyn + a.p[i][j]) % MODP;
    }
  }
  return wyn;
}
void readData() {
  char a, b;
  cin >> n;
  cin >> m;
  cin >> k;
  forb.h = m;
  forb.w = m;
  for (int i = 0; i < (m); ++i) {
    for (int j = 0; j < (m); ++j) {
      forb.p[i][j] = 1;
    }
  }
  for (int i = 0; i < (k); ++i) {
    scanf(" %c%c", &a, &b);
    forb.p[dajInt(a)][dajInt(b)] = 0;
  }
}
int main() {
  readData();
  if (n == 1) {
    printf("%d\n", m);
  } else {
    printf("%d\n", dajSume(pot(forb, n - 1)));
  }
}
