Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.
Let's assume that strings s and t have the same length n, then the function h(s, t) is defined as the number of positions in which the respective symbols of s and t are the same. Function h(s, t) can be used to define the function of Vasya distance ρ(s, t):
![](https://i-blog.csdnimg.cn/blog_migrate/fbf48cad17028bc0765a212145729aa8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/916b088e2c5077ce78ae442eccc4b557.png)
Vasya found a string s of length n on the Internet. Now he wants to count how many strings t there are such that the Vasya distance from the string s attains maximum possible value. Formally speaking, t must satisfy the equation: .
Vasya could not try all possible strings to find an answer, so he needs your help. As the answer may be very large, count the number of such strings modulo 109 + 7.
The first line of the input contains a single integer n (1 ≤ n ≤ 105).
The second line of the input contains a single string of length n, consisting of characters "ACGT".
Print a single number — the answer modulo 109 + 7.
1 C
1
2 AG
4
3 TTT
1
#include <bits/stdc++.h>
#define maxn 100005
#define MOD 1000000007
using namespace std;
typedef long long ll;
char str[maxn];
int d[30];
int main(){
// freopen("in.txt", "r", stdin);
int n;
scanf("%d%s", &n, str);
for(int i = 0; str[i]; i++){
d[str[i]-'A']++;
}
ll maxs = 0, cnt = 0;
for(int i = 0; i < 30; i++){
if(d[i] > maxs){
maxs = d[i];
cnt = 1;
}
else if(d[i] && d[i] == maxs){
cnt++;
}
}
ll ans = 1;
while(n--){
(ans *= cnt) %= MOD;
}
printf("%I64d\n", ans);
return 0;
}