#include <bits/stdc++.h>
using namespace std;
void multiply(int a[52][52], int b[52][52]) {
  int c[52][52];
  memset(c, 0, sizeof(c));
  for (int i = 0; i < 52; i++) {
    for (int j = 0; j < 52; j++) {
      for (int k = 0; k < 52; k++) {
        c[i][j] = (c[i][j] + (long long)a[i][k] * b[k][j]) % 1000000007;
      }
    }
  }
  for (int i = 0; i < 52; i++)
    for (int j = 0; j < 52; j++) a[i][j] = c[i][j];
}
void power(int a[52][52], long long b) {
  if (b == 1) return;
  int c[52][52];
  for (int i = 0; i < 52; i++)
    for (int j = 0; j < 52; j++) c[i][j] = a[i][j];
  power(a, b / 2);
  multiply(a, a);
  if (b & 1) multiply(a, c);
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  int m, k;
  cin >> m >> k;
  int a[52][52];
  memset(a, 0, sizeof(a));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 1;
    }
  }
  for (int i = 0; i < k; i++) {
    char x, y;
    cin >> x >> y;
    int p, q;
    if (x <= 'z' && x >= 'a')
      p = x - 'a';
    else
      p = x - 'A' + 26;
    if (y <= 'z' && y >= 'a')
      q = y - 'a';
    else
      q = y - 'A' + 26;
    a[p][q] = 0;
  }
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  power(a, n - 1);
  int ans = 0;
  for (int i = 0; i < 52; i++) {
    for (int j = 0; j < 52; j++) {
      ans = (ans + (long long)a[i][j]) % 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
