#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007;
vector<vector<long long> > matr, res, rmatr, rrmatr;
vector<vector<long long> > mult(vector<vector<long long> >& a,
                                vector<vector<long long> >& b) {
  int m = (int)(a).size(), n = (int)(a.front()).size(),
      k = (int)(b.front()).size();
  vector<vector<long long> > res(m, vector<long long>(k));
  for (int i = 0; i < (int)(m); i++) {
    for (int j = 0; j < (int)(k); j++) {
      for (int l = 0; l < (int)(n); l++) {
        res[i][j] = (res[i][j] + a[i][l] * b[l][j]) % p;
      }
    }
  }
  return res;
}
int ord(char c) {
  if (c >= 'a' && c <= 'z') {
    return c - 'a';
  }
  return c - 'A' + 26;
}
string tostr(long long a) {
  string res = "";
  while (a) {
    res += (char)(a % 10 + '0');
    a /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}
int main() {
  long long nn;
  int m, k;
  cin >> nn >> m >> k;
  string n = tostr(nn - 1);
  matr.resize(m, vector<long long>(m, 1));
  res.resize(m, vector<long long>(1, 1));
  for (int i = 0; i < (int)(k); i++) {
    string s;
    cin >> s;
    int a = ord(s[0]), b = ord(s[1]);
    matr[a][b] = 0;
  }
  rmatr.resize(m, vector<long long>(m));
  for (int i = 0; i < (int)(m); i++) {
    rmatr[i][i] = 1;
  }
  for (int i = 0; i < (int)((int)(n).size()); i++) {
    rrmatr = rmatr;
    for (int j = 0; j < (int)(9); j++) {
      rrmatr = mult(rrmatr, rmatr);
    }
    rmatr = rrmatr;
    for (int j = 0; j < (int)(n[i] - '0'); j++) {
      rmatr = mult(rmatr, matr);
    }
  }
  res = mult(rmatr, res);
  long long a = 0;
  for (int i = 0; i < (int)(m); i++) {
    a = (a + res[i][0]) % p;
  }
  cout << a << endl;
  cin >> n;
}
