#include <bits/stdc++.h>
using namespace std;
long long const M = 52 + 10, M2 = 1e7 + 10, mod = 1e9 + 7, inf = 1e18 + 10;
long long k;
struct mat {
  long long ma[M][M];
  mat(long long x) {
    for (long long i = 0; i < M - 5; i++) {
      for (long long j = 0; j < M - 5; j++) {
        ma[i][j] = 0;
      }
    }
    for (long long i = 0; i < M - 5; i++) ma[i][i] = x;
  }
};
mat ans(0);
mat operator*(mat &a, mat &b) {
  mat c(0);
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < k; j++) {
      for (long long l = 0; l < k; l++) {
        c.ma[i][j] += (a.ma[i][l] * b.ma[l][j]);
        c.ma[i][j] %= mod;
      }
    }
  }
  return c;
}
long long val(char tmp) {
  if (tmp - 'a' <= 25 && tmp - 'a' >= 0) return tmp - 'a';
  return tmp - 'A' + 26;
}
mat pw(mat &x, long long y) {
  mat tmp = x;
  mat c(1);
  while (y) {
    if (y % 2 == 1) {
      c = c * tmp;
    }
    tmp = tmp * tmp;
    y /= 2;
  }
  return c;
}
int32_t main() {
  long long n, m;
  cin >> n >> m >> k;
  swap(m, k);
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < k; j++) {
      ans.ma[i][j] = 1;
    }
  }
  for (long long i = 1; i <= m; i++) {
    char t, t2;
    cin >> t >> t2;
    long long x = val(t);
    long long y = val(t2);
    ans.ma[x][y] = 0;
  }
  ans = pw(ans, n - 1);
  long long all = 0;
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < k; j++) {
      all += ans.ma[i][j];
      all %= mod;
    }
  }
  cout << all;
}
