#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const long long inf = -1e18;
const long long M = 5 * 1e8;
long long n, m, k, a[100][100], ans, b[100][100], c[100][100];
char ch1, ch2;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      if (i == j) {
        a[i][j] = 1;
      }
      b[i][j] = 1;
    }
  }
  for (int i = 1; i <= k; i++) {
    cin >> ch1 >> ch2;
    long long t1 = 0, t2 = 0;
    long long c1h1 = (int)ch1, c1h2 = (int)ch2;
    if (c1h1 >= 'A' && c1h1 <= 'Z')
      c1h1 -= 'A' - 26, c1h1++;
    else {
      c1h1 -= 'a';
      c1h1++;
    }
    if (c1h2 >= 'A' && c1h2 <= 'Z')
      c1h2 -= 'A' - 26, c1h2++;
    else {
      c1h2 -= 'a';
      c1h2++;
    }
    b[c1h1][c1h2] = 0;
  }
  for (n--; n > 0; n = n / 2) {
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= m; j++) {
        c[i][j] = 0;
      }
    }
    if (n % 2 != 0) {
      for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
          for (int k = 1; k <= m; k++) {
            c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % mod;
          }
        }
      }
      for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
          a[i][j] = c[i][j];
        }
      }
      for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
          c[i][j] = 0;
        }
      }
    }
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= m; j++) {
        for (int k = 1; k <= m; k++) {
          c[i][j] = (c[i][j] + b[i][k] * b[k][j]) % mod;
        }
      }
    }
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= m; j++) {
        b[i][j] = c[i][j];
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      ans = (ans + a[i][j]) % mod;
    }
  }
  cout << ans;
  cin.get(), cin.get();
  return 0;
}
