#include <bits/stdc++.h>
using namespace std;
const int mx = 80;
long long mod = 1000 * 1000 * 1000 + 7;
long long a[mx][mx], res[mx][mx], b[mx][1], aa[mx][mx];
long long f[130];
int m;
vector<int> v;
void p2() {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      res[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      long long sum = 0;
      for (int k = 0; k < m; k++) {
        sum = (sum + (a[i][k] * a[k][j]) % mod) % mod;
      }
      res[i][j] = sum;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = res[i][j];
    }
  }
}
void p1() {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      res[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      long long sum = 0;
      for (int k = 0; k < m; k++) {
        sum = (sum + (a[i][k] * aa[k][j]) % mod) % mod;
      }
      res[i][j] = sum;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = res[i][j];
    }
  }
}
void pw(long long cnt) {
  if (cnt == 0) {
    return;
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i] == 1) {
      p1();
    } else {
      p2();
    }
  }
  return;
}
void process(long long n) {
  long long t = n;
  while (t > 1) {
    if (t % 2) {
      v.push_back(1);
      t--;
    }
    if (t > 1) {
      v.push_back(2);
      t /= 2;
    }
  }
}
void fs() {
  int r = 0;
  char ch = 'a';
  while (int(ch) <= int('z')) {
    f[int(ch)] = r;
    ch++;
    r++;
  }
  ch = 'A';
  while (int(ch) <= int('Z')) {
    f[int(ch)] = r;
    r++;
    ch++;
  }
}
int main() {
  for (int i = v.size() - 1; i >= 0; i--) {
    cout << v[i] << " ";
  }
  fs();
  long long n, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    b[i][0] = 1;
    for (int j = 0; j < m; j++) {
      a[i][j] = 1;
      aa[i][j] = 1;
    }
  }
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    a[f[int(s[0])]][f[int(s[1])]] = 0;
    aa[f[int(s[0])]][f[int(s[1])]] = 0;
  }
  if (n == 1) {
    cout << m;
    return 0;
  }
  process(n - 1);
  pw(n - 1);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 1; j++) {
      long long sum = 0;
      for (int k = 0; k < m; k++) {
        sum = (sum + (a[i][k] * b[k][j]) % mod) % mod;
      }
      ans = (ans + sum) % mod;
    }
  }
  cout << ans;
}
