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): $\rho(s, t) = \sum_{i = 0}^{n - 1} \sum_{j = 0}^{n - 1} h(\operatorname{shift}(s, i), \operatorname{shift}(t, j))$ where $\operatorname{shift}(s, i)$ 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

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: $\rho(s, t) = \operatorname{max}_{u :|u|=|s|} \rho(s, u)$.

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 10^9 + 7.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 10^5).

The second line of the input contains a single string of length n, consisting of characters "ACGT".


-----Output-----

Print a single number — the answer modulo 10^9 + 7.


-----Examples-----
Input
1
C

Output
1

Input
2
AG

Output
4

Input
3
TTT

Output
1



-----Note-----

Please note that if for two distinct strings t_1 and t_2 values ρ(s, t_1) и ρ(s, t_2) are maximum among all possible t, then both strings must be taken into account in the answer even if one of them can be obtained by a circular shift of another one.

In the first sample, there is ρ("C", "C") = 1, for the remaining strings t of length 1 the value of ρ(s, t) is 0.

In the second sample, ρ("AG", "AG") = ρ("AG", "GA") = ρ("AG", "AA") = ρ("AG", "GG") = 4.

In the third sample, ρ("TTT", "TTT") = 27

Difficulty: interview

Starter code:

Solutions:
def main():
    n = int(input())
    l = [0] * 85
    for c in input():
        l[ord(c)] += 1
    a, c, g, t = sorted(l[_] for _ in (65, 67, 71, 84))
    if g < t:
        print(1)
    elif c < g:
        print(pow(2, n, 1000000007))
    elif a < c:
        print(pow(3, n, 1000000007))
    else:
        print(pow(4, n, 1000000007))


def __starting_point():
    main()

__starting_point()

import sys
# sys.stdin = open('in.txt')
R = lambda: map(int, input().split())

n = int(input())
s = input()

ca = s.count('A')
cg = s.count('G')
cc = s.count('C')
ct = s.count('T')
mx = max(ca, cg, cc, ct)

sum = (ca==mx)+(cg==mx)+(cc==mx)+(ct==mx)

ans = 1

for i in range(n):
    ans = (ans*sum)%1000000007

print(ans)

n, s = input(), input()
a = {'A' : 0, 'C' : 1, 'G' : 2, 'T' : 3}
A = [0, 0, 0, 0]
for x in s:
    A[a[x]] += 1
MOD = 10 ** 9 + 7
print((A.count(max(A)) ** len(s)) % MOD)


n = int(input())
s = input()
num = s.count("A")
num1 = s.count("C")
num2 = s.count("T")
num3 = s.count("G")
num4 = max(num,num1,num2,num3)
num5 = 0
if num == num4:
    num5 += 1
if num1 == num4:
    num5 += 1
if num2 == num4:
    num5 += 1
if num3 == num4:
    num5 += 1
if num5 == 1 or n == 1:
    print(1)
else:
    print((num5**n)%(10**9+7))


n = int(input())
s = input()
a = [0] * 300
for i in s:
  a[ord(i)] += 1
print((a.count(max(a)) ** len(s)) % (10**9 + 7))


n = int(input().rstrip())
s = str(input().rstrip())
kol = 0
mx = 0
mas = [0] * 4
for i in range(n):
    if s[i] == 'A': mas[0] += 1
    if s[i] == 'C': mas[1] += 1
    if s[i] == 'G': mas[2] += 1
    if s[i] == 'T': mas[3] += 1
mx = max(mas)
kol = mas.count(mx)
print(kol ** n % 1000000007)

n = int(input())
s = input()
lst = {'A' : 0, 'C' : 0, 'G' : 0, 'T' : 0}
k, l = 0, 1
for i in s:
    lst[i] += 1
    if k < lst[i]:
        k = lst[i]
        l = 1
    else:
        if k == lst[i]:
            l += 1
print(l ** n % (10 ** 9 + 7))


n = int(input())
s = str(input()).upper()
probability_max = 0
Max = 0
modulo = 1000000007
base_acids = [0] * 4
for i in range(n):
    if s[i] == 'A': base_acids[0] += 1
    if s[i] == 'C': base_acids[1] += 1
    if s[i] == 'G': base_acids[2] += 1
    if s[i] == 'T': base_acids[3] += 1
kol = base_acids.count(max(base_acids))
print(kol ** n % modulo)
                       


N = int(input()) 
dna = input() 

A_num = 0 
C_num = 0 
G_num = 0 
T_num = 0 

for i in range(N): 
    if dna[i] == 'A': 
        A_num += 1 
 
    elif dna[i] == 'C': 
        C_num += 1 
 
    elif dna[i] == 'T': 
        T_num += 1 
 
    else: 
        G_num += 1 

numbers = [A_num, C_num, G_num, T_num] 

numbers.sort(key = lambda x: -x) 

if numbers[0] > numbers[1]: 
    print(1) 

elif numbers[1] > numbers[2]: 
    print(pow(2, N, 1000000007)) 

elif numbers[2] > numbers[3]: 
    print(pow(3, N, 1000000007)) 

else: 
    print(pow(4, N, 1000000007)) 


n=int(input())
s=input().strip()
a=s.count('T')
b=s.count('G')
c=s.count('C')
d=s.count('A')
q=max(a,b,c,d)
e=0
if q==a:
    e+=1
if q==b:
    e+=1
if q==c:
    e+=1
if q==d:
    e+=1
print(e**n%1000000007)

n = int(input())
s = input()
a = s.count('A')
c = s.count('C')
g = s.count('G')
t = s.count('T')
q = max(a,c,g,t)
cnt = [a,c,g,t].count(q)
print(pow(cnt, n, 1000000007))


n = int(input())
s = str(input()).upper()
probability_max = 0
Max = 0
modulo = 1000000007
base_acids = [0] * 4
for i in range(n):
    if s[i] == 'A': base_acids[0] += 1
    if s[i] == 'C': base_acids[1] += 1
    if s[i] == 'G': base_acids[2] += 1
    if s[i] == 'T': base_acids[3] += 1
kol = base_acids.count(max(base_acids))
print(kol ** n % modulo)


n = int(input())
s = input()
a = s.count('A')
c = s.count('C')
g = s.count('G')
t = s.count('T')
q = max(a,c,g,t)
cnt = [a,c,g,t].count(q)
print(pow(cnt, n, 1000000007))

length, dna = int(input()), input()
nums = [dna.count('A'), dna.count('C'), dna.count('G'), dna.count('T')]
print((nums.count(max(nums))**length) % 1000000007)


n = int(input())
s = input()
ca = cb = cc = cd =0
for c in s:
	ca += (c == 'A')
	cb += (c == 'C')
	cc += (c == 'G')
	cd += (c == 'T')
m = max(ca, cb, cc, cd)
count = (ca == m) + (cb == m) + (cc == m) + (cd == m)
print((count**n) % int(1e9+7))


n=int(input())
s=input()
ca=cb=cc=cd=0
for c in s:
	ca+=(c == 'A')
	cb+=(c == 'C')
	cc+=(c == 'G')
	cd+=(c == 'T')
m = max(ca, cb, cc, cd)
count = (ca == m) + (cb == m) + (cc == m) + (cd == m)
print ((count**n) % int(1e9+7))

#!/usr/bin/env python3

n = int(input())
s = input()

from collections import defaultdict
count = defaultdict(int)
for c in s:
    count[c] += 1
max_count = max(count.values())

k = sum([1 for value in list(count.values()) if value == max_count])

mod = 10**9 + 7
answer = 1
for i in range(n):
    answer = answer * k % mod

print(answer)


mod_by = 10**9 + 7

n = int(input())
s = input()

a = s.count("A")
c = s.count("C")
g = s.count("G")
t = s.count("T")

m = max(a,c,g,t)
ct = [a,c,g,t].count(m)

print(pow(ct, n, mod_by))

n=int(input())
s=input()
x=[s.count(i) for i in ['A','C','G','T']]

z=x.count(max(x))

print((z**n)%(10**9+7))


n, s = int(input()), input()
c = sorted(s.count(b) for b in 'ACGT')
print(c.count(c[-1]) ** n % (10 ** 9 + 7))

n, s = int(input()), input()
c = sorted(s.count(b) for b in 'ACGT')
print(pow(c.count(c[-1]), n, 10 ** 9 + 7))