原题链接


C. DNA Alignment



time limit per test



memory limit per test



input



output


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.

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):



Codeforces Round #295 (Div. 2)-C. DNA Alignment_sed

where 

Codeforces Round #295 (Div. 2)-C. DNA Alignment_i++_02

 is obtained from string 

s, by applying left circular shift 

i times. For example,

ρ("AGC", "CGT") = 

h("AGC", "CGT") + h("AGC", "GTC") + h("AGC", "TCG") + 

h("GCA", "CGT") + h("GCA", "GTC") + h("GCA", "TCG") + 

h("CAG", "CGT") + h("CAG", "GTC") + h("CAG", "TCG") = 

1 + 1 + 0 + 0 + 1 + 1 + 1 + 0 + 1 = 6 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: 

Codeforces Round #295 (Div. 2)-C. DNA Alignment_i++_03

.

109.


Input


n (1 ≤ n ≤ 105).

n, consisting of characters "ACGT".


Output


109.


Examples


input


1C


output


1


input


2AG


output


4


input


3TTT


output


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;
}