func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = ~0U >> 1;   const long long INF = ~0ULL >> 1;   template <class T>   inline void read(T &n) {     char c;     int flag = 1;     for (c = getchar(); !(c >=  0  && c <=  9  || c ==  - ); c = getchar())       ;     if (c ==  - )       flag = -1, n = 0;     else       n = c -  0 ;     for (c = getchar(); c >=  0  && c <=  9 ; c = getchar()) n = n * 10 + c -  0 ;     n *= flag;   }   const int maxn = 2100000;   const int mo = 1000000007;   int N, K, M, ans, vis[1000];   char s[maxn];   int nxt[maxn][26];   int dp[maxn];   void add(int &x, int y) {     x += y;     if (x >= mo) x -= mo;   }   int main(int argc, char *argv[]) {     scanf( %d%d , &N, &K);     scanf( %s , s + 1);     M = strlen(s + 1);     string temp =   ;     for (int i = (M); i >= (1); --i)       if (!vis[s[i]]) vis[s[i]] = true, temp = s[i] + temp;     for (int i = ( a ); i <= ( a  + K - 1); ++i)       if (!vis[i]) temp = (char)i + temp;     for (int i = (0); i < (N); ++i) s[++M] = temp[i % temp.size()];     for (int j = (0); j < (K); ++j) nxt[M + 1][j] = M + 1;     for (int i = (M); i >= (1); --i) {       memcpy(nxt[i], nxt[i + 1], sizeof(nxt[i]));       nxt[i][s[i] -  a ] = i;     }     int cur = 0;     dp[0] = 1;     for (int i = (0); i < (M); ++i) {       int flag = false;       for (int j = (0); j < (K); ++j)         if (nxt[i + 1][j] <= M) add(dp[nxt[i + 1][j]], dp[i]);     }     for (int i = (0); i <= (M); ++i) add(ans, dp[i]);     printf( %d n , ans);     return 0;   }   