#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
void read(int &x){
	char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar();
	for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}

LL modd = 1000000007;
LL pow(LL x, int y){
	LL ret(1);
	for (; y; y>>=1){
		if (y&1) ret = ret*x%modd;
		x = x*x%modd;
	}
	return ret;
}

int n, b[1000], ans;
char a[110000];
int main(){
	scanf("%d%s", &n, a+1);
	FOR(i,'A','T') b[i] = 0;
	REP(i,n) ++b[a[i]];
	int p(0), q(0);
	FOR(i,'A','T'){
		if (b[i] > p) p = b[i];
		if (b[i] == p) q += b[i];
	}
	ans = int(pow(q, n));
	printf("%d\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
void read(int &x){
	char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar();
	for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}

LL modd = 1000000007;
LL pow(LL x, int y){
	LL ret(1);
	for (; y; y>>=1){
		if (y&1) ret = ret*x%modd;
		x = x*x%modd;
	}
	return ret;
}

int n, b[1000], ans;
char a[110000];
int main(){
	scanf("%d%s", &n, a+1);
	FOR(i,'A','T') b[i] = 0;
	REP(i,n) ++b[a[i]];
	int p(0), q(0);
	FOR(i,'A','T'){
		if (b[i] > p){ p = b[i]; q = 0; }
		if (b[i] == p) ++q;
	}
	ans = pow(q, n);
	printf("%I64d\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
void read(int &x){
	char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar();
	for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}

LL modd = 1000000007;
LL pow(LL x, int y){
	LL ret(1);
	for (; y; y>>=1){
		if (y&1) ret = ret*x%modd;
		x = x*x%modd;
	}
	return ret;
}

int n, b[1000], ans;
char a[110000];
int main(){
	scanf("%d%s", &n, a+1);
	FOR(i,'A','T') b[i] = 0;
	REP(i,n) ++b[a[i]];
	int p(0), q(0);
	FOR(i,'A','T'){
		if (b[i] > p){ p = b[i]; q = 0; }
		if (b[i] == p) ++q;
	}
	ans = int(pow(q, n));
	printf("%d\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
void read(int &x){
	char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar();
	for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}

LL modd = 1000000007;
LL powmod(LL x, int y){
	LL ret(1);
	for (; y; y>>=1){
		if (y&1) ret = ret*x%modd;
		x = x*x%modd;
	}
	return ret;
}

int n, b[1000], ans;
char a[110000];
int main(){
	scanf("%d%s", &n, a+1);
	FOR(i,'A','T') b[i] = 0;
	REP(i,n) ++b[a[i]];
	int p(0), q(0);
	FOR(i,'A','T'){
		if (b[i] > p){ p = b[i]; q = 0; }
		if (b[i] == p) ++q;
	}
	ans = int(powmod(q, n));
	printf("%d\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
void read(int &x){
	char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar();
	for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}

LL modd = 1000000007;
LL powmod(LL x, int y){
	LL ret(1);
	for (; y; y>>=1){
		if (y&1) ret = ret*x%modd;
		x = x*x%modd;
	}
	return ret;
}

int n, b[1000], ans;
char a[110000];
int main(){
	scanf("%d%s", &n, a+1);
	FOR(i,'A','T') b[i] = 0;
	REP(i,n) ++b[a[i]];
	int p(0), q(0);
	FOR(i,'A','T'){
		if (b[i] > p){ p = b[i]; q = 0; }
		if (b[i] == p) ++q;
	}
	ans = powmod(q, n);
	printf("%I64d\n", ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define MAXN 1000
using namespace std;
int main()
{
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define rFOR(i, x, y) for(int i = x; i >= y; --i)
#define MS(x, y) memset(x, y, sizeof(x))
#define MAXN 100005
#define ll long long
using namespace std;
const int mod = 1000000007;
int N;
int a[4];
//"ATCG"
void init()
{
    char ch;
    scanf("%d", &N);
    FOR(i, 1, N)
    {
        scanf(" %c", &ch);
        if(ch == 'A') ++a[0];
        if(ch == 'T') ++a[1];
        if(ch == 'C') ++a[2];
        if(ch == 'G') ++a[3];
    }
}
ll dp[MAXN][4];
ll num[MAXN][4];
void solve()
{
//    num[0][0] = num[0][1] = num[0][2] = num[0][3] = 1;
//    FOR(i, 0, 3) num[0][i] = a[i];
    num[0][0] = 1;
    FOR(i, 1, N)
    {
        FOR(j, 0, 3)
        FOR(k, 0, 3)
        {
            if(dp[i][j] == dp[i-1][k] + a[j])
            {
                num[i][j] = (num[i][j] + num[i-1][k]) % mod;
            }
            if(dp[i][j] < dp[i-1][k] + a[j])
            {
                dp[i][j] = dp[i-1][k] + a[j];
                num[i][j] = num[i-1][k];
            }
        }
        ll best = 0;
        FOR(j, 0, 3)
            best = max(best, dp[i][j]);
        FOR(j, 0, 3)
        if(dp[i][j] < best)
            num[i][j] = 0;
    }
//    FOR(i, 0, N) cerr << dp[i][0] << ' ' << dp[i][1] << ' ' << dp[i][2] << ' ' << dp[i][3] << endl;
//    FOR(i, 0, N) cerr << num[i][0] << ' ' << num[i][1] << ' ' << num[i][2] << ' ' << num[i][3] << endl;
    ll ans = (num[N][0] + num[N][1] + num[N][2] + num[N][3]) % mod;
    cout << ans << endl;
}
int main()
{
    init();
    solve();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define rFOR(i, x, y) for(int i = x; i >= y; --i)
#define MS(x, y) memset(x, y, sizeof(x))
#define MAXN 100005
#define ll long long
using namespace std;
const int mod = 1000000009;
int N;
int a[4];
//"ATCG"
void init()
{
    char ch;
    scanf("%d", &N);
    FOR(i, 1, N)
    {
        scanf(" %c", &ch);
        if(ch == 'A') ++a[0];
        if(ch == 'T') ++a[1];
        if(ch == 'C') ++a[2];
        if(ch == 'G') ++a[3];
    }
}
ll dp[MAXN][4];
ll num[MAXN][4];
void solve()
{
//    num[0][0] = num[0][1] = num[0][2] = num[0][3] = 1;
//    FOR(i, 0, 3) num[0][i] = a[i];
    num[0][0] = 1;
    FOR(i, 1, N)
    {
        FOR(j, 0, 3)
        FOR(k, 0, 3)
        {
            if(dp[i][j] == dp[i-1][k] + a[j])
            {
                num[i][j] = (num[i][j] + num[i-1][k]) % mod;
            }
            if(dp[i][j] < dp[i-1][k] + a[j])
            {
                dp[i][j] = dp[i-1][k] + a[j];
                num[i][j] = num[i-1][k];
            }
        }
        ll best = 0;
        FOR(j, 0, 3)
            best = max(best, dp[i][j]);
        FOR(j, 0, 3)
        if(dp[i][j] < best)
            num[i][j] = 0;
    }
//    FOR(i, 0, N) cerr << dp[i][0] << ' ' << dp[i][1] << ' ' << dp[i][2] << ' ' << dp[i][3] << endl;
//    FOR(i, 0, N) cerr << num[i][0] << ' ' << num[i][1] << ' ' << num[i][2] << ' ' << num[i][3] << endl;
    ll ans = (num[N][0] + num[N][1] + num[N][2] + num[N][3]) % mod;
    cout << ans << endl;
}
int main()
{
    init();
    solve();
    return 0;
}


#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[1001];
int mod=1000000007;
inline long long power(long long x,int y)
{
	 long long t=1;
     while(y!=0)
     {
          if(y%2==1)
               t=t*x%mod;
          y=y/2;
          x=x*x%mod;
     }
     return t;
}
int main()
{
     int n;
     scanf("%d",&n);
     int i;
     char x[1001];
     scanf("%s",x);
     for(i=0;i<=n-1;i++)
          s[x[i]-'A'+1]++;
     sort(s,s+1+26);
     for(i=25;i>=1;i--)
          if(s[i]!=s[i+1])
               break;
     printf("%I64d\n",power(26-i,n));
     return 0;
}


#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[1001];
int mod=1000000007;
inline long long power(long long x,int y)
{
	 long long t=1;
     while(y!=0)
     {
          if(y%2==1)
               t=t*x%mod;
          y=y/2;
          x=x*x%mod;
     }
     return t;
}
char x[100001];
int main()
{
     int n;
     scanf("%d",&n);
     int i;
     scanf("%s",x);
     for(i=0;i<=n-1;i++)
          s[x[i]-'A'+1]++;
     sort(s+1,s+1+26);
     for(i=25;i>=1;i--)
          if(s[i]!=s[i+1])
               break;
     printf("%I64d\n",power(26-i,n));
     return 0;
}


#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[1001];
int mod=1000000007;
inline long long power(long long x,int y)
{
	 long long t=1;
     while(y!=0)
     {
          if(y%2==1)
               t=t*x%mod;
          y=y/2;
          x=x*x%mod;
     }
     return t;
}
int main()
{
     int n;
     scanf("%d",&n);
     int i;
     char x[1001];
     scanf("%s",x);
     for(i=0;i<=n-1;i++)
          s[x[i]-'A'+1]++;
     sort(s+1,s+1+26);
     for(i=25;i>=1;i--)
          if(s[i]!=s[i+1])
               break;
     printf("%I64d\n",power(26-i,n));
     return 0;
}


#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[1001];
long long mod=1000000007;
inline long long power(long long x,int y)
{
	 long long t=1;
     while(y!=0)
     {
          if(y%2==1)
               t=t*x%mod;
          y=y/2;
          x=x*x%mod;
     }
     return t;
}
int main()
{
     int n;
     scanf("%d",&n);
     int i;
     char x[1001];
     scanf("%s",x);
     for(i=0;i<=n-1;i++)
          s[x[i]-'A'+1]++;
     sort(s,s+1+26);
     for(i=25;i>=1;i--)
          if(s[i]!=s[i+1])
               break;
     printf("%I64d\n",power(26-i,n));
     return 0;
}


/* DHUOJ solution #346952 @ 2018-07-12 19:13:41.395 */

//
//  main.cpp
//  cd- A - DNA
//
//  Created by 沈夏馨 on 18/7/12.
//  Copyright © 2018年 Xiaxin Shen. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int N;
ll kinds=0;
ll counts=0;
map<int, int> mapCounts;
map<char, int> mapAGCT;

void initial(){
    mapCounts.clear();
    mapAGCT.clear();
}
void input(){
    getchar();
    kinds=0;
    counts=0;
    for(int i=0;i<N;i++){
        char temp;
        scanf("%c",&temp);
        mapAGCT[temp]++;
    }
    /////
    for(map<char,int>::iterator it=mapAGCT.begin();it!=mapAGCT.end();it++){
        mapCounts[it->second]++;
    }
    for(map<int,int>::iterator it=mapCounts.begin();it!=mapCounts.end();it++){
        if(it->first>counts) counts=it->second;
    }
    kinds=counts;
}
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;//奇数
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
void computing(){
    cout<<mod_pow(kinds, N, mod)<<endl;
}

int main() {
    while(scanf("%d",&N)!=EOF){
        initial();
        input();
        computing();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#define mod 1000000000+7
using namespace std;
int dna[4]={0};
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A') a++;
        if(s[i]=='G') b++;
        if(s[i]=='T') c++;
        if(s[i]=='C') d++;
    }
    int maxx=max(a,b);int maxy=max(c,d);
    int maxi=max(maxx,maxy);
    //cout<<maxi<<endl;
    if(a==maxi) cnt++;
    if(b==maxi) cnt++;
    if(c==maxi) cnt++;
    if(d==maxi) cnt++;

    //cout<<cnt<<endl;
    long long int ans=1;
    for(int i=1;i<=n;i++){
        ans*=cnt;
        //cout<<cnt<<endl;
        ans=ans%(1000000000+7);
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;
string s;
int n;
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>s;
    set<char>st;
    for(int i=0 ; i <n ;i ++)st.insert(s[i]);
    ll r= 1;
    for(int i=0 ; i <n ;i ++){
        r *= st.size();
        r %= mod;
    }
    cout<<r<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;
string s;
int n;
int st[100];
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>s;
    for(int i=0 ; i <n ;i ++)st[s[i]-'A']++;
    int mx = 0;
    for(int i=0 ; i <26 ;i ++)mx =max(mx,st[i]);
    ll r1  =0;
    for(int i=0 ; i <26 ;i ++)if(mx == st[i])r1++;

    ll r= 1;
    for(int i=0 ; i <n ;i ++){
        r *= r1;
        r %= mod;
    }
    cout<<r<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std ;

int n , mod = 1000 * 1000 * 1000 + 7 , cnt[50] , ma , cow ;

string s ;

long long ans = 1 ;

int main()
{
    cin >> n >> s ;
    for ( int i = 0 ; i < n ; i ++ )
    {
        int t = s[i] - 'A' ;
        cnt[t] ++ ;
        ma = max(ma , cnt[t] ) ;
    }

    for ( int i = 0 ; i < 30 ; i ++ )
    {
        if (cnt[i] == ma)
            cow ++ ;
    }

    for ( int i = 0 ; i < n ; i ++ )
        ans = (ans * cow + mod ) % mod ;

    cout << ans ;
}


#include <bits/stdc++.h>

using namespace std ;

int n , mod = 1000 * 1000 * 1000 + 7 , ans ;

string s ;

int main()
{
    cin >> n >> s ;
    ans = n ;
    for ( int i = 1 ; i < n ; i ++ )
        ans = (ans * n + mod) % mod ;
    cout << ans ;
}


#include <bits/stdc++.h>

using namespace std ;

int n , mod = 1000 * 1000 * 1000 + 7 , ans ;

string s ;

int main()
{
    cin >> n >> s ;
    for ( int i = 0 ; i < n ; i ++ )
        n = (n * n + mod) % mod ;
    cout << n ;
}


/* DHUOJ solution #346808 @ 2018-07-12 14:44:36.860 */

#include <iostream>
#include <stdio.h>
#include <algorithm>
#define ll long long
using namespace std;
const int mod=1e9+7;
string s;
int num[4];
ll quick_mod(ll a, ll n, ll p) ;   //快速幂 a^n % p
int main()
{
    int n,x=0;;
    ll ans=0;
    scanf("%d",&n);
    cin>>s;
    for (int i=0; i<n; i++)
    {
        if (s[i]=='A')
            num[0]++;
        if (s[i]=='C')
            num[1]++;
        if (s[i]=='G')
            num[2]++;
        if (s[i]=='T')
            num[3]++;
    }
    int m=max(num[0],num[1]);
    m=max(num[2],m);
    m=max(num[3],m);
    for (int i=0; i<4; i++)
        if (m==num[i])
            x++;
    ans=quick_mod(x,n,mod);
    printf("%d\n",ans);
    return 0;
}
ll quick_mod(ll a, ll n, ll p)    //快速幂 a^n % p
{
    ll ans = 1;
    while(n)
    {
        if(n & 1) ans = ans * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return ans;
}


#include <cmath>
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;
const int MOD = 1e9 + 7;
typedef long long LL;

LL pow_mod(LL a,LL m){
     LL ans=1;
     while(m){
         if(m&1) ans=ans*a%MOD;
         a=a*a%MOD;
         m>>=1;
     }

     return ans;
}

LL arr[30]={0};
int n;
int main()
{
    scanf("%d",&n);
    getchar();
    LL ans=0;
    for(int i=0;i<n;i++){
        char ch;
        ch=getchar();
        arr[ch-'A']++;
        ans=max(ans,arr[ch-'A']);
    }
    int num=0;
    for(int i=0;i<30;i++){
        if(ans==arr[i]) num++;
    }
    printf("%I64d",pow_mod(num,n));
    return 0;
}


/* DHUOJ solution #346739 @ 2018-07-12 13:45:27.952 */

#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
int n;
string str;
int num[4];
long long quick_mod(long long a,long long b)
{
    long long res=1;
    while(b)
    {
        if(b%2==1)
        {
            res=((res%mod)*(a%mod))%mod;
        }
        b=b/2;
        a=((a%mod)*(a%mod))%mod;
    }
    return res;
}
int main()
{
    while(cin>>n)
    {
        cin>>str;
        memset(num,0,sizeof(num));
        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='A')
            {
                num[0]++;
            }
            else if(str[i]=='C')
            {
                num[1]++;
            }
            else if(str[i]=='G')
            {
                num[2]++;
            }
            else if(str[i]=='T')
            {
                num[3]++;
            }
        }
        int res=0;
        for(int i=0;i<=3;i++)
        {
            res=max(res,num[i]);
        }
        int ans=0;
        for(int i=0;i<=3;i++)
        {
            if(res==num[i])
            {
                ans++;
            }
        }
        long long sum=quick_mod(ans,n);
        cout<<sum<<endl;
    }
    return 0;
}


/* DHUOJ solution #346785 @ 2018-07-12 14:20:28.632 */

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <map>
typedef long long ll;
using namespace std;
const long long p=1000000000+7;
int a[30];
int n;
bool cmp(int a,int b){
    return a>b;
}

ll quick(ll a,ll b ,ll c){

    ll ans=1;

    while(b){

        if(b&1){

            ans=(ans*a)%c;

        }

        b>>=1;

        a=(a*a)%c;

    }

    return ans;

}

int main()
{
    while(~scanf("%d",&n)){
        memset(a,0,sizeof(a));
        int mx=0;
        char key;
        int num=0;
        for(int i=0;i<n;i++){
            char ch;
            cin>>ch;
            a[ch-'A']++;
            /*if(a[ch-'A']>mx){
                mx=a[ch-'A'];
                key=ch;
            }
            else*/
        }
        sort(a,a+28,cmp);
        /*for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            if(a[i]<a[j])    //如果前一个元素小于后一个元素
            {
                int temp;        //临时变量
                temp = a[i];
                a[i] = a[j]; //大的元素到前一个位置
                a[j] = temp;   //小的元素到后一个位置
            }
        }
    }*/

        mx=a[0];
        for(num=0;a[num]==mx&&num<n;num++);
        if(num==1)cout<<1<<endl;
        else
        cout<<quick(num,n,p)<<endl;
    }

    return 0;
}


#include<cstdio>
#include<iostream>
#include<fstream>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstring>
#include<ctime>
#include<map>
#define REP(i,N) for(int i=0;i<N;i++)
#define foru(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define ford(i,a,b) for(int i=a,_b=b;i>=_b;i--)
#define read freopen("","r",stdin)
#define write freopen("","w",stdout)
#define fi first
#define se second
#define sz size()
#define pb push_back
#define sqr(a) (a)*(a)
#define setp(x) cout.precision(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const float eps=1e-8;
const ll lloo=1e18;
const int oo=1e9;
const int base=int(1e9)+7;
int f[100010][4],sl[100010][4],sum[100010][4];
int n;
string s;
int a[100010];
int main(){
    int n;
    cin >> n;
    cin >> s;
    s=s+s;
    REP(i,s.sz) {
        switch(s[i]) {
            case 'A': a[i]=0; break;
            case 'C': a[i]=1; break;
            case 'G': a[i]=2; break;
            case 'T': a[i]=3; break;
        }
    }
    REP(i,2*n) REP(j,4) sum[i+1][j]=sum[i][j]+(a[i]==j);
    f[0][1]=0;
    sl[0][1]=1;
    foru(i,1,n) REP(j,4) {
        int smax=0,luu=0;
        REP(z,4) smax=max(smax,f[i-1][z]);
        REP(z,4) if (f[i-1][z]==smax) luu=(sl[i-1][z]+luu)%base;
        f[i][j]=smax+sum[i+n-1][j]-sum[i-1][j];
        sl[i][j]=luu;
    }
    int smax=0,luu=0;
    REP(j,4) smax=max(smax,f[n][j]);
    REP(j,4) if (f[n][j]==smax) luu=(luu+sl[n][j])%base;
    cout << luu;
}


#include<cstdio>
#include<iostream>
#include<fstream>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstring>
#include<ctime>
#include<map>
#define REP(i,N) for(int i=0;i<N;i++)
#define foru(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define ford(i,a,b) for(int i=a,_b=b;i>=_b;i--)
#define read freopen("","r",stdin)
#define write freopen("","w",stdout)
#define fi first
#define se second
#define sz size()
#define pb push_back
#define sqr(a) (a)*(a)
#define setp(x) cout.precision(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const float eps=1e-8;
const ll lloo=1e18;
const int oo=1e9;
const int base=int(1e9)+7;
int sl[100010][4],sum[200010][4];
ll f[100010][4];
int n;
string s;
int a[200010];
int main(){
    int n;
    cin >> n;
    cin >> s;
    s=s+s;
    REP(i,s.sz) {
        switch(s[i]) {
            case 'A': a[i]=0; break;
            case 'C': a[i]=1; break;
            case 'G': a[i]=2; break;
            case 'T': a[i]=3; break;
        }
    }
    REP(i,2*n) REP(j,4) sum[i+1][j]=sum[i][j]+(a[i]==j);
    f[0][1]=0;
    sl[0][1]=1;
    foru(i,1,n) REP(j,4) {
        ll smax=0,luu=0;
        REP(z,4) smax=max(smax,f[i-1][z]);
        REP(z,4) if (f[i-1][z]==smax) luu=(sl[i-1][z]+luu)%base;
        f[i][j]=smax+sum[i+n-1][j]-sum[i-1][j];
        sl[i][j]=luu;
    }
    ll smax=0,luu=0;
    REP(j,4) smax=max(smax,f[n][j]);
    REP(j,4) if (f[n][j]==smax) luu=(luu+sl[n][j])%base;
    cout << luu;
}


#include<cstdio>
#include<iostream>
#include<fstream>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstring>
#include<ctime>
#include<map>
#define REP(i,N) for(int i=0;i<N;i++)
#define foru(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define ford(i,a,b) for(int i=a,_b=b;i>=_b;i--)
#define read freopen("","r",stdin)
#define write freopen("","w",stdout)
#define fi first
#define se second
#define sz size()
#define pb push_back
#define sqr(a) (a)*(a)
#define setp(x) cout.precision(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const float eps=1e-8;
const ll lloo=1e18;
const int oo=1e9;
const int base=int(1e9)+7;
int f[100010][4],sl[100010][4],sum[200010][4];
int n;
string s;
int a[200010];
int main(){
    int n;
    cin >> n;
    cin >> s;
    s=s+s;
    REP(i,s.sz) {
        switch(s[i]) {
            case 'A': a[i]=0; break;
            case 'C': a[i]=1; break;
            case 'G': a[i]=2; break;
            case 'T': a[i]=3; break;
        }
    }
    REP(i,2*n) REP(j,4) sum[i+1][j]=sum[i][j]+(a[i]==j);
    f[0][1]=0;
    sl[0][1]=1;
    foru(i,1,n) REP(j,4) {
        int smax=0,luu=0;
        REP(z,4) smax=max(smax,f[i-1][z]);
        REP(z,4) if (f[i-1][z]==smax) luu=(sl[i-1][z]+luu)%base;
        f[i][j]=smax+sum[i+n-1][j]-sum[i-1][j];
        sl[i][j]=luu;
    }
    int smax=0,luu=0;
    REP(j,4) smax=max(smax,f[n][j]);
    REP(j,4) if (f[n][j]==smax) luu=(luu+sl[n][j])%base;
    cout << luu;
}


#include<cstdio>
#include<iostream>
#include<fstream>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstring>
#include<ctime>
#include<map>
#define REP(i,N) for(int i=0;i<N;i++)
#define foru(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define ford(i,a,b) for(int i=a,_b=b;i>=_b;i--)
#define read freopen("","r",stdin)
#define write freopen("","w",stdout)
#define fi first
#define se second
#define sz size()
#define pb push_back
#define sqr(a) (a)*(a)
#define setp(x) cout.precision(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const float eps=1e-8;
const ll lloo=1e18;
const int oo=1e9;
const int base=int(1e9)+7;
int sl[100010][4],sum[200010][4];
ll f[100010][4];
int n;
string s;
int a[200010];
int main(){
    int n;
    cin >> n;
    cin >> s;
    s=s+s;
    REP(i,s.sz) {
        switch(s[i]) {
            case 'A': a[i]=0; break;
            case 'C': a[i]=1; break;
            case 'G': a[i]=2; break;
            case 'T': a[i]=3; break;
        }
    }
    REP(i,2*n) REP(j,4) sum[i+1][j]=sum[i][j]+(a[i]==j);
    f[0][1]=0;
    sl[0][1]=1;
    foru(i,1,n) REP(j,4) {
        int smax=0,luu=0;
        REP(z,4) smax=max(smax,f[i-1][z]);
        REP(z,4) if (f[i-1][z]==smax) luu=(sl[i-1][z]+luu)%base;
        f[i][j]=smax+sum[i+n-1][j]-sum[i-1][j];
        sl[i][j]=luu;
    }
    int smax=0,luu=0;
    REP(j,4) smax=max(smax,f[n][j]);
    REP(j,4) if (f[n][j]==smax) luu=(luu+sl[n][j])%base;
    cout << luu;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <ctime>
#include <numeric>

using namespace std;

#define sqr(a) ((a)*(a))
#define two(a) (1 << (a))
#define has(mask, a) ((mask) & two(a) ? 1 : 0)

void load() {
}

string s;

void solve() {
    int n;
    cin >> n;
    cin >> s;
    sort(s.begin(), s.end());
    int mx = 0, c = 0, cur = 1;
    for (int i = 1;i <= n;i++) {
        if (i < n && s[i] == s[i - 1]) {
            cur++;
            continue;
        }

        if (cur > mx) {
            mx = cur;
            c = 1;
        } else if (cur == mx) {
            c++;
        }

        cur = 0;
    }

    int ans = c;
    for (int i = 0;i < n - 1;i++) {
        ans = ans * 1ll * c % 1000000007;
    }

    cout << ans << endl;
}

int main() {
    #ifdef MY_LOCAL
        freopen ("a.in", "r", stdin);
    #endif

    load();
    solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <ctime>
#include <numeric>

using namespace std;

#define sqr(a) ((a)*(a))
#define two(a) (1 << (a))
#define has(mask, a) ((mask) & two(a) ? 1 : 0)

void load() {
}

string s;

void solve() {
    int n;
    cin >> n;
    cin >> s;
    sort(s.begin(), s.end());
    int mx = 0, c = 0, cur = 1;
    for (int i = 1;i <= n;i++) {
        if (i < n && s[i] == s[i - 1]) {
            cur++;
            continue;
        }

        if (cur > mx) {
            mx = cur;
            c = 1;
        } else if (cur == mx) {
            c++;
        }
    }

    int ans = c;
    for (int i = 0;i < n - 1;i++) {
        ans = ans * 1ll * c % 1000000007;
    }

    cout << ans << endl;
}

int main() {
    #ifdef MY_LOCAL
        freopen ("a.in", "r", stdin);
    #endif

    load();
    solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <ctime>
#include <numeric>

using namespace std;

#define sqr(a) ((a)*(a))
#define two(a) (1 << (a))
#define has(mask, a) ((mask) & two(a) ? 1 : 0)

void load() {
}

string s;

void solve() {
    int n;
    cin >> n;
    cin >> s;
    sort(s.begin(), s.end());
    int mx = 0, c = 0, cur = 1;
    for (int i = 1;i <= n;i++) {
        if (i < n && s[i] == s[i - 1]) {
            cur++;
            continue;
        }

        if (cur > mx) {
            mx = cur;
            c = 1;
        } else if (cur == mx) {
            c++;
        }

        cur = 1;
    }

    int ans = c;
    for (int i = 0;i < n - 1;i++) {
        ans = ans * 1ll * c % 1000000007;
    }

    cout << ans << endl;
}

int main() {
    #ifdef MY_LOCAL
        freopen ("a.in", "r", stdin);
    #endif

    load();
    solve();

    return 0;
}


# include <bits/stdc++.h>

//Defines
# define Pi 3.14159265358979323846
# define pf first
# define ps second
# define mp make_pair
# define IN1  freopen ("input.txt", "r", stdin);
# define OUT1 freopen ("output.txt", "w", stdout);
# define IN2  freopen ("", "r", stdin);
# define OUT2 freopen ("", "w", stdout);

/*NOTES
    %I64d
*/

using namespace std;

    typedef long long ll;
    typedef long double ld;
    typedef pair <int, int> Pii;

    int n,i,ans,x;
    int ch[10000];
    string s;
int main(){
 #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
 #endif
//    IN1; OUT1;

     cin>>n;
     cin>>s;
     for (int i=0;i<s.length();i++)
        ch[s[i]]++;
       sort(ch+1,ch+1001);

       for (i=1000;i>=0;i--){
        if (ch[1000]!=ch[i]) break;
        ans++;
       }
       x=1;
       for (i=1;i<=n;i++)
            x=ans*x %1000000007;
       cout<<x;
    return 0;
}


# include <bits/stdc++.h>

//Defines
# define Pi 3.14159265358979323846
# define pf first
# define ps second
# define mp make_pair
# define IN1  freopen ("input.txt", "r", stdin);
# define OUT1 freopen ("output.txt", "w", stdout);
# define IN2  freopen ("", "r", stdin);
# define OUT2 freopen ("", "w", stdout);

/*NOTES
    %I64d
*/

using namespace std;

    typedef long long ll;
    typedef long double ld;
    typedef pair <int, int> Pii;

 long long n,i,ans,x;
    int ch[10000];
    string s;
int main(){
 #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
 #endif
//    IN1; OUT1;

     cin>>n;
     cin>>s;
     for (int i=0;i<s.length();i++)
        ch[s[i]]++;
       sort(ch+1,ch+1001);

       for (i=1000;i>=0;i--){
        if (ch[1000]!=ch[i]) break;
        ans++;
       }
       x=1;
       for (i=1;i<=n;i++)
            x=ans*x %1000000007;
       cout<<x;
    return 0;
}


# include <bits/stdc++.h>

//Defines
# define Pi 3.14159265358979323846
# define pf first
# define ps second
# define mp make_pair
# define IN1  freopen ("input.txt", "r", stdin);
# define OUT1 freopen ("output.txt", "w", stdout);
# define IN2  freopen ("", "r", stdin);
# define OUT2 freopen ("", "w", stdout);

/*NOTES
    %I64d
*/

using namespace std;

    typedef long long ll;
    typedef long double ld;
    typedef pair <int, int> Pii;

    int n,i,ans,x;
    int ch[10000];
    string s;
int main(){
 #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
 #endif
//    IN1; OUT1;

     cin>>n;
     cin>>s;
     for (int i=0;i<s.length();i++)
        ch[s[i]]++;
       sort(ch+1,ch+1000);
       for (i=1;i<=n;i++){
        if (ch[1]!=ch[i]) break;
        ans++;
       }
       x=1;
       for (i=1;i<=n;i++)
            x=ans*x %1000000007;
       cout<<x;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb(a) push_back(a)
#define rep(i,a) for(int i = 0 ; i < a ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b; ++i)
#define MAXX(a,b) ((a>=b)?a:b)
#define MOD 1000000007
using namespace std;
long long fact[100001];
ll powmod(ll a,  ll b){
    if(b==0)
        return 1 ;
    ll x= powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (x*a)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string s ;
    cin >> n;
    cin >> s;
    map<char,ll> occ;
    bool ok = true ;
    int cnt = 0 ;
    for(int i = 0 ; i < s.length() ; ++i){
        if(occ[s[i]])
            ok = false;
        else
            cnt++ ;
        occ[s[i]]++;
    }
    long long den = 1 ;
    fact[0] = 1;
    for(int i = 1 ; i <= n; ++i){
        fact[i] = (fact[i-1]*i)%MOD ;
    }
    ll modinv=1;
    for(map<char,ll>::iterator itr = occ.begin() ; itr != occ.end() ; ++itr){
        ll C = itr->second ;
        modinv = (modinv*fact[C])%MOD ;
    }
    modinv = powmod(modinv,MOD-2) ;
    ll ans = (fact[n]*modinv)%MOD ;
    if(n==1){
        cout << 1 << "\n" ;
    }
    else {
        if(ok){
            cout << (ans + cnt)%MOD  << "\n" ;
        }
        else
            cout << ans << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
ll powmod(ll a , ll b){
    if(b==0)
        return 1 ;
    ll x=  powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (a*x)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string str;
    cin >>n ;
    cin >> str;
    set<char> S ;
    for(int i = 0 ; i < str.length() ; ++i){
        if(S.find(str[i]) == S.end()){
            S.insert(str[i]) ;
        }
    }
    ll sz = S.size(),z ;
    if(sz==1){
        cout << 1 << "\n" ;
    }
    else{
        string s1 , s2 ;
        for(int i = 0 ; i < n/2 ; ++i)
            s1 += str[i];
        for(int i = n/2 ; i < n ; ++i)
            s2 += str[i];
        if(s1==s2)
            z=n/2 ;
        else
            z=0;
        cout << (powmod(sz,n) - z + MOD)%MOD << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
ll powmod(ll a , ll b){
    if(b==0)
        return 1 ;
    ll x=  powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (a*x)%MOD ;
    }
    return x ;
}
int main(){
 //   freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string str;
    cin >>n ;
    cin >> str;
    set<char> S ;
    for(int i = 0 ; i < str.length() ; ++i){
        if(S.find(str[i]) == S.end()){
            S.insert(str[i]) ;
        }
    }
    ll sz = S.size(),z ;
    if(sz==1){
        cout << 1 << "\n" ;
    }
    else{
        string s1 , s2 ;
        for(int i = 0 ; i < n/2 ; ++i)
            s1 += str[i];
        for(int i = n/2 ; i < n ; ++i)
            s2 += str[i];
        if(s1==s2)
            z=n/2 ;
        else
            z=n;
        cout << powmod(sz,z)  << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb(a) push_back(a)
#define rep(i,a) for(int i = 0 ; i < a ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b; ++i)
#define MAXX(a,b) ((a>=b)?a:b)
#define MOD 1000000007
using namespace std;
long long fact[100001];
ll powmod(ll a,  ll b){
    if(b==0)
        return 1 ;
    ll x= powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (x*a)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string s ;
    cin >> n;
    cin >> s;
    map<char,ll> occ;
    bool ok = true ;
    int cnt = 0 ;
    int flag = 0 ;
    for(int i = 0 ; i < s.length() ; ++i){
        if(occ[s[i]])
            ok = false;
        else
            cnt++ ;
        occ[s[i]]++;
        if(occ[s[i]] == n)
            flag = 1;
    }
    long long den = 1 ;

    if((n==1)or(flag==1)){
        cout << 1 << "\n" ;
    }
    else {
        if(ok){
            cout << (n + cnt)%MOD  << "\n" ;
        }
        else
            cout << n << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb(a) push_back(a)
#define rep(i,a) for(int i = 0 ; i < a ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b; ++i)
#define MAXX(a,b) ((a>=b)?a:b)
#define MOD 1000000007
using namespace std;
long long fact[100001];
ll powmod(ll a,  ll b){
    if(b==0)
        return 1 ;
    ll x= powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (x*a)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string s ;
    cin >> n;
    cin >> s;
    map<char,ll> occ;
    bool ok = true ;
    int cnt = 0 ;
    int flag = 0 ;
    for(int i = 0 ; i < s.length() ; ++i){
        if(occ[s[i]])
            ok = false;
        else
            cnt++ ;
        occ[s[i]]++;
        if(occ[s[i]] == n)
            flag = 1;
    }
    long long den = 1 ;

    if((n==1)or(flag==1)){
        cout << 1 << "\n" ;
    }
    else {
        int shifts = 0 ;
        if(n%2==0){
            string s1 , s2 ;
            for(int i = 0 ; i < n/2 ; ++i)
                s1 += s[i] ;
            for(int i = n/2 ; i < n; ++i)
                s2 += s[i] ;
            if(s1==s2)
                shifts = n/2 ;
            else
                shifts = n ;
        }
        else
            shifts = n;
        if(ok){
            cout << (shifts + cnt)%MOD  << "\n" ;
        }
        else
            cout << shifts << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
ll powmod(ll a , ll b){
    if(b==0)
        return 1 ;
    ll x=  powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (a*x)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string str;
    cin >>n ;
    cin >> str;
    set<char> S ;
    for(int i = 0 ; i < str.length() ; ++i){
        if(S.find(str[i]) == S.end()){
            S.insert(str[i]) ;
        }
    }
    ll sz = S.size() ;
    if(sz==1){
        cout << 1 << "\n" ;
    }
    else{
        cout << powmod(sz,n) << "\n" ;
    }
    return 0 ;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int MOD = 1000000007;
ll powmod(ll a , ll b){
    if(b==0)
        return 1 ;
    ll x=  powmod(a,b/2) ;
    x = (x*x)%MOD ;
    if(b&1){
        x = (a*x)%MOD ;
    }
    return x ;
}
int main(){
  //  freopen("input.txt","r",stdin) ;
    ios_base::sync_with_stdio(0) ;
    int n ;
    string str;
    cin >>n ;
    cin >> str;
    set<char> S ;
    map<char,ll> f;
    for(int i = 0 ; i < str.length() ; ++i){
        if(S.find(str[i]) == S.end()){
            S.insert(str[i]) ;
        }
        f[str[i]]++ ;
    }
    ll maxi = 0 ;
    for(map<char,ll>::iterator itr = f.begin() ; itr != f.end() ; ++itr){
        maxi = max(itr->second,maxi) ;
    }
    ll sz = S.size(),z ;
    for(map<char,ll>::iterator itr = f.begin() ; itr != f.end() ; ++itr){
        if(itr->second < maxi)
            sz--;
    }
    if(sz==1){
        cout << 1 << "\n" ;
    }
    else{
        cout << powmod(sz,n) << "\n" ;
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[11111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<LL,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr)(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[11111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr){
		(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
		ans=(ans*ifac[itr->first*itr->second])%MOD;
	}
	ans = (ans*fac[n])%MOD;
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[111111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	REP(i,10)OLL(i,ifac[i]);
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr){
		(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
	}
	ans = (ans*fac[n])%MOD;
	REPIT(mm,itr) {
		ans=(ans*ifac[itr->first*itr->second])%MOD;
	}
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[111111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr){
		(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
		ans=(ans*ifac[itr->first*itr->second])%MOD;
	}
	ans = (ans*fac[n])%MOD;
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[111111];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	//REP(i,10)OLL(i,ifac[i]);
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	int m = 0;
	REP(i,4)m = max(m,cnt[i]);
	int cc = 0;
	REP(i,4)if(cnt[i]==m)cc++;
	LL ans = 1;
	REP(i,n)ans = (ans*cc)%MOD;
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[111111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	//REP(i,10)OLL(i,ifac[i]);
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr){
		(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
	}
	ans = (ans*fac[n])%MOD;
	REPIT(mm,itr) {
		ans=(ans*ifac[itr->first*itr->second])%MOD;
	}
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 222222;
const int INF = 1<<30;
int n;
char s[11111];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y) {
		if(y&1)(ret*=x)%MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	set<char> ss;
	for(int i=0;s[i];++i)ss.insert(s[i]);
	int kk = ss.size();
	OL(POW(kk,n));
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[11111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=100000;++i){
		fac[i] = (fac[i-1] * i)%MOD;
		ifac[i] = (ifac[i-1] * POW(i,MOD-2))%MOD;
	}
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)if(cnt[i])mm[cnt[i]]++;
	REPIT(mm,itr){
		(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
		ans=(ans*ifac[itr->first*itr->second])%MOD;
	}
	ans = (ans*fac[n])%MOD;
	OL(ans);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 111111;
const int INF = 1<<30;
int n;
char s[11111];
LL fac[maxn],ifac[maxn];
LL POW(LL x,int y) {
	LL ret = 1;
	while(y){
		if(y&1)(ret*=x)%=MOD;
		x = (x*x)%MOD;
		y>>=1;
	}
	return ret;
}
int cnt[4];
int main(int argc, char const *argv[])
{
	RI(n);
	RS(s);
	for(int i=0;s[i];++i)
		if(s[i]=='A')cnt[0]++;
		else if(s[i]=='T')cnt[1]++;
		else if(s[i]=='C')cnt[2]++;
		else if(s[i]=='G')cnt[3]++;
	LL ans = 1;
	map<int,int> mm;
	REP(i,4)mm[cnt[i]]++;
	REPIT(mm,itr)(ans*= POW(itr->second,itr->first*itr->second))%=MOD;
	OL(ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10],tot,a[10],b[10];
ll mod=1000000007;
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
	return -1;
}
inline int jie(int x)
{
	int t=1;
	for1(i,x)t=(ll)t*i%mod;
	return t;
}
inline int inv(int x)
{
	int t=1;
	for(int i=mod-2;i;i>>=1,x=(ll)x*x%mod)
	 if(i&1)t=(ll)t*x%mod;
	return t;
}
int main()
{
    n=read();
    for1(i,n)
    {
    	char ch=getchar();
    	while(f(ch)==-1)ch=getchar();
    	v[f(ch)]++;
    }
    sort(v,v+4);
    for0(i,3)
	{
	  if(i==0||v[i]!=v[i-1])tot++;
	  a[tot]=v[i];b[tot]++;
    }
    int ans=jie(n);
    for1(i,tot)
	{
	  ans=(ll)ans*inv(jie(a[i]*b[i]))%mod;
	  for1(j,b[i]*a[i])ans=(ll)ans*b[i]%mod;
    }
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 100000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define mod 1000000007
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10];
char s[maxn];
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
}
int main()
{
    n=read();
    scanf("%s",s);
    for0(i,n-1)v[f(s[i])]=1;
    ll m=0;
    for0(i,3)if(v[i])m++;
    ll ans=1;
	for1(i,n)ans=ans*m%mod;
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10],tot,a[10],b[10];
ll mod=1000000007;
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
	return -1;
}
inline int jie(int x)
{
	int t=1;
	for1(i,x)t=(ll)t*i%mod;
	return t;
}
inline int inv(int x)
{
	int t=1;
	for(int i=mod-2;i;i>>=1,x=(ll)x*x%mod)
	 if(i&1)t=(ll)t*x%mod;
	return t;
}
int main()
{
    n=read();
    for1(i,n)
    {
    	char ch=getchar();
    	while(f(ch)==-1)ch=getchar();
    	v[f(ch)]++;
    }
    sort(v,v+4);
    for0(i,3)
	{
	  if(i==0||v[i]!=v[i-1])tot++;
	  a[tot]=v[i];b[tot]++;
    }
    int ans=1;
    for1(i,n)ans=(ll)ans*b[tot]%mod;
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10];
char s[maxn];
ll mod=1000000007;
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
}
int main()
{
    n=read();
    scanf("%s",s);
    for0(i,n-1)v[f(s[i])]=1;
    ll m=0;
    for0(i,3)if(v[i])m++;
    ll ans=1;
	for1(i,n)ans=ans*m%mod;
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10],tot,a[10],b[10];
ll mod=1000000007;
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
	return -1;
}
inline int jie(int x)
{
	int t=1;
	for1(i,x)t=(ll)t*i%mod;
	return t;
}
inline int inv(int x)
{
	int t=1;
	for(int i=mod-2;i;i>>=1,x=(ll)x*x%mod)
	 if(i&1)t=(ll)t*x%mod;
	return t;
}
int main()
{
    n=read();
    for1(i,n)
    {
    	char ch=getchar();
    	while(f(ch)==-1)ch=getchar();
    	v[f(ch)]++;
    }
    sort(v,v+4);
    for0(i,3)
	{
	  if(i==0||v[i]!=v[i-1])tot++;
	  a[tot]=v[i];b[tot]++;
    }
    int ans=jie(n);
    for1(i,tot)if(a[i])
	{
	  ans=(ll)ans*inv(jie(a[i]*b[i]))%mod;
	  for1(j,b[i]*a[i])ans=(ll)ans*b[i]%mod;
    }
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 100000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define mod 1000000007
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10];
char s[maxn];
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
}
int main()
{
    n=read();
    scanf("%s",s);
    for0(i,n-1)v[f(s[i])]=1;
    int m=0;
    for0(i,3)if(v[i])m++;
    ll ans=1;
	for1(i,n)ans=(ans*m)%mod;
	cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+5
#define maxm 100000+5
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
#define lch k<<1,l,mid
#define rch k<<1|1,mid+1,r
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    return x*f;
}
int n,v[10];
ll mod=1000000007;
inline int f(char ch)
{
	if(ch=='A')return 0;
	if(ch=='G')return 1;
	if(ch=='C')return 2;
	if(ch=='T')return 3;
	return -1;
}
int main()
{
    n=read();
    for1(i,n)
    {
    	char ch=getchar();
    	while(f(ch)==-1)ch=getchar();
    	v[f(ch)]=1;
    }
    ll m=0;
    for0(i,3)m+=v[i];
    ll ans=1;
	for1(i,n)ans=ans*m%mod;
	cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<string.h>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<functional>
#include<algorithm>
#include<memory.h>
#include<assert.h>
#include<numeric>
#include<limits.h>
using namespace std;
const int mod=1e9+7;
long long ksm(long long a,long long b)
{
	long long res=1ll;
	while(b!=0)
	{
		if(b&1)res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res;
}
long long n;
int vis[4];
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		if(c=='A')vis[0]++;
		else if(c=='G')vis[1]++;
		else if(c=='C')vis[2]++;
		else if(c=='T')vis[3]++;
	}
	sort(vis,vis+4);
	int maxn=vis[3];
	long long cnt=0;
	for(int i=0;i<4;i++)if(vis[i]==maxn)cnt++;
	cout<<ksm(cnt,n)<<endl;
	return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<string.h>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<functional>
#include<algorithm>
#include<memory.h>
#include<assert.h>
#include<numeric>
#include<limits.h>
using namespace std;
const int mod=1e9+7;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b!=0)
	{
		if(b&1)res=(res*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return res;
}
set<int>s;
int main()
{
	int n;
	scanf("%d",&n);
	s.clear();
	for(int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		s.insert((int)(c-64));
	}
	int sz=s.size();
	cout<<ksm(sz,n)<<endl;
	return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<string.h>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<functional>
#include<algorithm>
#include<memory.h>
#include<assert.h>
#include<numeric>
#include<limits.h>
using namespace std;
const int mod=1e9+7;
long long ksm(int a,int b)
{
	long long res=1;
	while(b!=0)
	{
		if(b&1)res=(res*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return res;
}
set<int>s;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		s.insert((int)(c-64));
	}
	int sz=s.size();
	cout<<ksm(sz,n)<<endl;
	return 0;
}


#include <cstdio>
#include <algorithm>

typedef long long i64;

const int N = 100000 + 10, MOD = 1000000007;

int main() {
  int n;
  static char s[N];
  scanf("%d %s", &n, s);
  static int cnt[4];
  for (char *i = s; *i; ++i) {
    if (*i == 'A') ++cnt[0];
    if (*i == 'T') ++cnt[1];
    if (*i == 'C') ++cnt[2];
    if (*i == 'G') ++cnt[3];
  }
  std::sort(cnt, cnt + 4);
  int ans = 1;
  int x = 3;
  while (x >= 0 && cnt[x] == cnt[3]) --x;
  for (int i = n; i--;) ans = (3LL - x) * ans % MOD;
  printf("%d\n", ans);
  return 0;
}


#include <cstdio>
#include <cstring>
#include <set>

typedef long long i64;

const int N = 100000 + 10, MOD = 1000000007;

int main() {
  int n;
  static char s[N];
  scanf("%d %s", &n, s);
  std::set<char> pool(s, s + n);
  int ans = 1;
  for (int x = pool.size(); n--;) ans = (i64)x * ans % MOD;
  printf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const char v[4] = {'A', 'G', 'T', 'C'};
const long long q = int(1e9) + 7;

int n, a[1000000 + 10];
long long res;
char s[100000 + 10];

int main()
{
    //freopen("in.inp", "r", stdin);

    scanf("%d", &n);
    scanf("%s", &s);
    for (int i = 0; i < n; i++) a[s[i]]++;

    res = 1;
    for (int i = 0; i < n; i++)
    {
        long long d = 0;
        int m = a[s[i]];
        for (int j = 0; j < 4; j++) m = max(m, a[v[j]]);
        for (int j = 0; j < 4; j++) if (a[v[j]] == m) d++;
        res = (res * d) % q;
    }

    printf("%lld", res);
}


#include <bits/stdc++.h>

using namespace std;

const char v[4] = {'A', 'G', 'T', 'C'};
const long long q = int(1e9) + 7;

int n, a[1000000 + 10];
long long res;
char s[100000 + 10];

int main()
{
    //freopen("in.inp", "r", stdin);

    scanf("%d", &n);
    scanf("%s", &s);
    for (int i = 0; i < n; i++) a[s[i]]++;

    res = 1;
    for (int i = 0; i < n; i++)
    {
        long long d = 0;
        int m = a[s[i]];
        for (int j = 0; j < 4; j++) m = max(m, a[v[j]]);
        for (int j = 0; j < 4; j++) if (a[s[j]] == m) d++;
        res = (res * d) % q;
    }

    printf("%lld", res);
}


#include <bits/stdc++.h>

using namespace std;

const char v[4] = {'A', 'G', 'T', 'C'};
const long long q = int(1e9) + 7;

int n, a[1000000 + 10];
long long res;
char s[100000 + 10];

int main()
{
    //freopen("in.inp", "r", stdin);

    scanf("%d", &n);
    scanf("%s", &s);
    for (int i = 0; i < n; i++) a[s[i]]++;

    res = 1;
    for (int i = 0; i < n; i++)
    {
        long long d = 1;
        for (int j = 0; j < 4; j++)
            if (v[j] != s[i] && a[v[j]] == a[s[i]]) d++;
        res = (res * d) % q;
    }

    printf("%lld", res);
}


#include<bits/stdc++.h>
#define set(p) memset(p,-1,sizeof(p))
#define clr(p) memset(p,0,sizeof(p))
#define ll long long int
#define llu unsigned long long int
#define si(n)                   scanf("%d",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                                   scanf("%s",n)
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define pii pair<int,int>
#define pb(x) push_back(x)
#define v(x) vector<x>
using namespace std;

int gcd(int a,int b)
{
 int r, i;
  while(b!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

long long int power(long long int x,long long int y,ll mod)
{
    long long int temp,ty,my;

    if( y == 0)
        return 1;
    temp = power(x, y/2,mod);
    ty=(temp%mod)*(temp%mod);
    if (y%2 == 0)
        {

                return ty%mod;
        }
    else
        {
                my=(x%mod)*(ty%mod);
                return my%mod;
        }
}

long long int maxi(long long int a,long long int b)
{
        return a>b?a:b;
}

ll maxx(ll a,ll b,ll c,ll d,ll e)
{
    return maxi(maxi(maxi(a,b),maxi(c,d)),e);
}

struct abhi
{
       ll val;
       ll pos;
};

struct abhi brr[100010];

bool cmp(struct abhi x,struct abhi y)
{
        return x.pos<y.pos;
}

char ss[100010];
ll ar[100100];
ll b[100100];
//int b[100000];
vector< pair<int,int> > abhi;
ll mod=1000000007;

ll fact[1000100];

void pre()
{
    ll i,j;
    fact[0]=1;
    for(i=1;i<100010;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
    }
}

ll solve(ll n,ll a1,ll a2,ll a3,ll a4)
{
    ll t,g,k,p;

    t=fact[n]%mod;
    //cout<<t<<"\n";
    t=(t*power(fact[a1],mod-2,mod))%mod;
    //cout<<t<<"\n";
    t=(t*power(fact[a2],mod-2,mod))%mod;
    //cout<<t<<"\n";
    t=(t*power(fact[a3],mod-2,mod))%mod;
    //cout<<t<<"\n";
    t=(t*power(fact[a4],mod-2,mod))%mod;
    //cout<<t<<"\n";
    return t;
}

int main()
{
        ios_base::sync_with_stdio(false);
        pre();
        ll t,m,i,n,r,j,k=0,p,kk=0;

        cin>>n;
        string s;
        cin>>s;
        k=s.size();

        char po=s[0];
        int cc=0;
        rep(i,0,k)
        {
            if(s[i]==po)
                cc++;
        }

        if(cc==n)
            cout<<"1\n";
        else{
        int cn[6];
        cn[0]=0;
        cn[1]=0;
        cn[2]=0;
        cn[3]=0;

        for(i=0;i<k;i++)
        {
            if(s[i]=='A')
                cn[0]++;
            else if(s[i]=='C')
            {
                cn[1]++;
            }
            else if(s[i]=='G')
            {
                cn[2]++;
            }
            else
            {
                cn[3]++;
            }
        }

        string ini=s;
        ll cnt=1;
        int fg=0;
        rep(i,0,k)
        {
            string te="";
            te=te+ini.substr(i+1,n-i-1) + ini.substr(0,i+1);
            //cout<<te<<"\n";
            if(te==ini)
            {
                fg=1;
                break;
            }
            else
            {
                cnt++;
            }
        }
        //cout<<cnt<<"---\n";

        ll an=cn[0]*cn[0] + cn[1]*cn[1] + cn[2]*cn[2] +cn[3]*cn[3];
        ll a1,a2,a3,a4;
        //cout<<n<<"\n";

        a1=cn[0]*n;
        a2=cn[1]*n;
        a3=cn[2]*n;
        a4=cn[3]*n;

        ll ma=maxx(a1,a2,a3,a4,an);

        ll fin=0;
        if(ma==an)
        {
            ll gh=solve(n,cn[0],cn[1],cn[2],cn[3]);
            //cout<<gh<<"\n";
            fin=(fin+gh)%mod;
        }
        //cout<<"fin->"<<fin<<"\n";
        //cout<<cn[0]<<" "<<cn[1]<<" "<<cn[2]<<" "<<cn[3]<<"--- cn  --\n";
        if(ma==a1)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a2)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a3)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a4)
        {
            fin=(fin+1)%mod;
        }

        cout<<fin<<"\n";
        }
        return 0;
}


#include<bits/stdc++.h>
#define set(p) memset(p,-1,sizeof(p))
#define clr(p) memset(p,0,sizeof(p))
#define ll long long int
#define llu unsigned long long int
#define si(n)                   scanf("%d",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                                   scanf("%s",n)
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define pii pair<int,int>
#define pb(x) push_back(x)
#define v(x) vector<x>
using namespace std;

int gcd(int a,int b)
{
 int r, i;
  while(b!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

long long int power(long long int x,long long int y)
{
    long long int temp,ty,my;
    long long int mod;
    mod=1000000007;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    ty=(temp%mod)*(temp%mod);
    if (y%2 == 0)
        {

                return ty%mod;
        }
    else
        {
                my=(x%mod)*(ty%mod);
                return my%mod;
        }
}

long long int maxi(long long int a,long long int b)
{
        return a>b?a:b;
}

ll maxx(ll a,ll b,ll c,ll d,ll e)
{
    return maxi(maxi(maxi(a,b),maxi(c,d)),e);
}

struct abhi
{
       ll val;
       ll pos;
};

struct abhi brr[100010];

bool cmp(struct abhi x,struct abhi y)
{
        return x.pos<y.pos;
}

char ss[100010];
ll ar[100100];
ll b[100100];
//int b[100000];
vector< pair<int,int> > abhi;

int main()
{
        ios_base::sync_with_stdio(false);
        ll t,m,i,n,r,j,k=0,p,kk=0;
        ll mod=1000000007;
        cin>>n;
        string s;
        cin>>s;
        k=s.size();

        char po=s[0];
        int cc=0;
        rep(i,0,k)
        {
            if(s[i]==po)
                cc++;
        }

        if(cc==n)
            cout<<"1\n";
        else{
        int cn[6];
        cn[0]=0;
        cn[1]=0;
        cn[2]=0;
        cn[3]=0;

        for(i=0;i<k;i++)
        {
            if(s[i]=='A')
                cn[0]++;
            else if(s[i]=='C')
            {
                cn[1]++;
            }
            else if(s[i]=='G')
            {
                cn[2]++;
            }
            else
            {
                cn[3]++;
            }
        }

        ll an=cn[0]*cn[0] + cn[1]*cn[1] + cn[2]*cn[2] +cn[3]*cn[3];
        ll a1,a2,a3,a4;

        a1=cn[0]*n;
        a2=cn[1]*n;
        a3=cn[2]*n;
        a4=cn[3]*n;

        ll ma=maxx(a1,a2,a3,a4,an);

        ll fin=0;
        if(ma==an)
        {
            fin=(fin+n)%mod;
        }
        if(ma==a1)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a2)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a3)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a4)
        {
            fin=(fin+1)%mod;
        }

        cout<<fin<<"\n";
        }
        return 0;
}


#include<bits/stdc++.h>
#define set(p) memset(p,-1,sizeof(p))
#define clr(p) memset(p,0,sizeof(p))
#define ll long long int
#define llu unsigned long long int
#define si(n)                   scanf("%d",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                                   scanf("%s",n)
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define pii pair<int,int>
#define pb(x) push_back(x)
#define v(x) vector<x>
using namespace std;

int gcd(int a,int b)
{
 int r, i;
  while(b!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

long long int power(long long int x,long long int y)
{
    long long int temp,ty,my;
    long long int mod;
    mod=1000000007;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    ty=(temp%mod)*(temp%mod);
    if (y%2 == 0)
        {

                return ty%mod;
        }
    else
        {
                my=(x%mod)*(ty%mod);
                return my%mod;
        }
}

long long int maxi(long long int a,long long int b)
{
        return a>b?a:b;
}

ll maxx(ll a,ll b,ll c,ll d,ll e)
{
    return maxi(maxi(maxi(a,b),maxi(c,d)),e);
}

struct abhi
{
       ll val;
       ll pos;
};

struct abhi brr[100010];

bool cmp(struct abhi x,struct abhi y)
{
        return x.pos<y.pos;
}

char ss[100010];
ll ar[100100];
ll b[100100];
//int b[100000];
vector< pair<int,int> > abhi;

int main()
{
        ios_base::sync_with_stdio(false);
        ll t,m,i,n,r,j,k=0,p,kk=0;
        ll mod=1000000007;
        cin>>n;
        string s;
        cin>>s;
        k=s.size();

        char po=s[0];
        int cc=0;
        rep(i,0,k)
        {
            if(s[i]==po)
                cc++;
        }

        if(cc==n)
            cout<<"1\n";
        else{
        int cn[6];
        cn[0]=0;
        cn[1]=0;
        cn[2]=0;
        cn[3]=0;

        for(i=0;i<k;i++)
        {
            if(s[i]=='A')
                cn[0]++;
            else if(s[i]=='C')
            {
                cn[1]++;
            }
            else if(s[i]=='G')
            {
                cn[2]++;
            }
            else
            {
                cn[3]++;
            }
        }

        string ini=s;
        ll cnt=1;
        int fg=0;
        rep(i,0,k)
        {
            string te="";
            te=te+ini.substr(i+1,n-i-1) + ini.substr(0,i+1);
            //cout<<te<<"\n";
            if(te==ini)
            {
                fg=1;
                break;
            }
            else
            {
                cnt++;
            }
        }
        //cout<<cnt<<"---\n";

        ll an=cn[0]*cn[0] + cn[1]*cn[1] + cn[2]*cn[2] +cn[3]*cn[3];
        ll a1,a2,a3,a4;
        //cout<<n<<"\n";

        a1=cn[0]*n;
        a2=cn[1]*n;
        a3=cn[2]*n;
        a4=cn[3]*n;

        ll ma=maxx(a1,a2,a3,a4,an);

        ll fin=0;
        if(ma==an)
        {
            if(fg==1)
            {
                fin=(fin+cnt)%mod;
                //cout<<"po\n";
            }
            else
            {
                fin=(fin+n)%mod;
                //cout<<"poi\n";
            }
        }
        //cout<<"fin->"<<fin<<"\n";
        //cout<<cn[0]<<" "<<cn[1]<<" "<<cn[2]<<" "<<cn[3]<<"--- cn  --\n";
        if(ma==a1)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a2)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a3)
        {
            fin=(fin+1)%mod;
        }
        if(ma==a4)
        {
            fin=(fin+1)%mod;
        }

        cout<<fin<<"\n";
        }
        return 0;
}


#include<bits/stdc++.h>
#define set(p) memset(p,-1,sizeof(p))
#define clr(p) memset(p,0,sizeof(p))
#define ll long long int
#define llu unsigned long long int
#define si(n)                   scanf("%d",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                                   scanf("%s",n)
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define pii pair<int,int>
#define pb(x) push_back(x)
#define v(x) vector<x>
using namespace std;

int gcd(int a,int b)
{
 int r, i;
  while(b!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

long long int power(long long int x,long long int y,ll mod)
{
    long long int temp,ty,my;

    if( y == 0)
        return 1;
    temp = power(x, y/2,mod);
    ty=(temp%mod)*(temp%mod);
    if (y%2 == 0)
        {

                return ty%mod;
        }
    else
        {
                my=(x%mod)*(ty%mod);
                return my%mod;
        }
}

long long int maxi(long long int a,long long int b)
{
        return a>b?a:b;
}

ll maxx(ll a,ll b,ll c,ll d,ll e)
{
    return maxi(maxi(maxi(a,b),maxi(c,d)),e);
}

struct abhi
{
       ll val;
       ll pos;
};

struct abhi brr[100010];

bool cmp(struct abhi x,struct abhi y)
{
        return x.pos<y.pos;
}

char ss[100010];
ll ar[100100];
ll b[100100];
//int b[100000];
vector< pair<int,int> > abhi;

int main()
{
        ios_base::sync_with_stdio(false);
        ll t,m,i,n,r,j,k=0,p,kk=0;

        cin>>n;
        string s;
        cin>>s;
        k=s.size();

        char po=s[0];
        int cc=0;
        rep(i,0,k)
        {
            if(s[i]==po)
                cc++;
        }

        int cn[6];
        cn[0]=0;
        cn[1]=0;
        cn[2]=0;
        cn[3]=0;

        for(i=0;i<k;i++)
        {
            if(s[i]=='A')
                cn[0]++;
            else if(s[i]=='C')
            {
                cn[1]++;
            }
            else if(s[i]=='G')
            {
                cn[2]++;
            }
            else
            {
                cn[3]++;
            }
        }

        sort(cn,cn+3);
        j=3;
        ll cnt=0;
        ll big=cn[3];
        j=3;
        while(j>=0)
        {
            if(cn[j]==big)
            {
                cnt++;
            }
            j--;
        }
        ll mod=1000000007;
        cout<<power(cnt,n,mod)<<"\n";

        return 0;
}


#include<bits/stdc++.h>
#define set(p) memset(p,-1,sizeof(p))
#define clr(p) memset(p,0,sizeof(p))
#define ll long long int
#define llu unsigned long long int
#define si(n)                   scanf("%d",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                                   scanf("%s",n)
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define pii pair<int,int>
#define pb(x) push_back(x)
#define v(x) vector<x>
using namespace std;

int gcd(int a,int b)
{
 int r, i;
  while(b!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

long long int power(long long int x,long long int y,ll mod)
{
    long long int temp,ty,my;

    if( y == 0)
        return 1;
    temp = power(x, y/2,mod);
    ty=(temp%mod)*(temp%mod);
    if (y%2 == 0)
        {

                return ty%mod;
        }
    else
        {
                my=(x%mod)*(ty%mod);
                return my%mod;
        }
}

long long int maxi(long long int a,long long int b)
{
        return a>b?a:b;
}

ll maxx(ll a,ll b,ll c,ll d,ll e)
{
    return maxi(maxi(maxi(a,b),maxi(c,d)),e);
}

struct abhi
{
       ll val;
       ll pos;
};

struct abhi brr[100010];

bool cmp(struct abhi x,struct abhi y)
{
        return x.pos<y.pos;
}

char ss[100010];
ll ar[100100];
ll b[100100];
//int b[100000];
vector< pair<int,int> > abhi;

int main()
{
        ios_base::sync_with_stdio(false);
        ll t,m,i,n,r,j,k=0,p,kk=0;

        cin>>n;
        string s;
        cin>>s;
        k=s.size();

        char po=s[0];
        int cc=0;
        rep(i,0,k)
        {
            if(s[i]==po)
                cc++;
        }

        int cn[6];
        cn[0]=0;
        cn[1]=0;
        cn[2]=0;
        cn[3]=0;

        for(i=0;i<k;i++)
        {
            if(s[i]=='A')
                cn[0]++;
            else if(s[i]=='C')
            {
                cn[1]++;
            }
            else if(s[i]=='G')
            {
                cn[2]++;
            }
            else
            {
                cn[3]++;
            }
        }

        //cout<<cn[0]<<" "<<cn[1]<<" "<<cn[2]<<" "<<cn[3]<<" "<<"\n";

        sort(cn,cn+4);
        j=3;
        ll cnt=0;
        ll big=cn[3];
        //cout<<big<<"\n";
        j=3;
        while(j>=0)
        {
            if(cn[j]==big)
            {
                cnt++;
            }
            j--;
        }
        ll mod=1000000007;
        //cout<<cnt<<" "<<n<<"\n";
        cout<<power(cnt,n,mod)<<"\n";

        return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <stack>
#include <vector>
#include <sstream>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#define FFI freopen("in.txt", "r", stdin)
#define maxn 100010
#define INF 0x3f3f3f3f
#define inf 10000000
#define MOD 1000000007
#define ULL unsigned long long
#define LL long long
#define _setm(houge) memset(houge, INF, sizeof(houge))
#define _setf(houge) memset(houge, -1, sizeof(houge))
#define _clear(houge) memset(houge, 0, sizeof(houge))
using namespace std;

int main() {
    int n;
    string s;
    while(cin >> n >> s) {
        int len = s.length();
        long long ans = 1;
        int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
        for(int i = 0; i < len; ++ i) {
            if(s[i] == 'A') a1++;
            else if(s[i] == 'T') a2++;
            else if(s[i] == 'G') a3++;
            else a4++;
        }
        int _max = max(a1, a2);
        _max = max(_max, a3);
        _max = max(_max, a4);
        int k = 0;
        if(a1 == _max) {
            k ++;
        }
        if(a2 == _max) {
            k ++;
        }
        if(a3 == _max) {
            k ++;
        }
        if(a4 == _max) {
            k ++;
        }
        if(k == 1) ans = 1;
        else if(k == 2) {
            for(int i = 0; i < n; ++ i) {
                ans *= 2;
                ans %= MOD;
            }
        }
        else if(k == 3) {
            for(int i = 0; i < n; ++ i) {
                ans *= 3;
                ans %= MOD;
            }
        }
        else {
            for(int i = 0; i < n; ++ i) {
                ans *= 4;
                ans %= MOD;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <stack>
#include <vector>
#include <sstream>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#define FFI freopen("in.txt", "r", stdin)
#define maxn 100010
#define INF 0x3f3f3f3f
#define inf 10000000
#define MOD 1000000007
#define ULL unsigned long long
#define LL long long
#define _setm(houge) memset(houge, INF, sizeof(houge))
#define _setf(houge) memset(houge, -1, sizeof(houge))
#define _clear(houge) memset(houge, 0, sizeof(houge))
using namespace std;

int count_(int n) {
    int cnt = 0;
    while(n) {
        if(n%2) cnt++;
        n /= 2;
    }
    return cnt;
}

int main() {
    int n;
    string s;
    while(cin >> n >> s) {
        int len = s.length();
        long long ans = 1;
        int now = 0;
        for(int i = 0; i < len; ++ i) {
            if(s[i] == 'A') now |= 1;
            else if(s[i] == 'T') now |= 2;
            else if(s[i] == 'G') now |= 4;
            else now |= 8;
        }
        int k = count_(now);
        if(k == 1) ans = 1;
        else if(k == 2) {
            for(int i = 0; i < n; ++ i) {
                ans *= 2;
                ans %= MOD;
            }
        }
        else if(k == 3) {
            for(int i = 0; i < n; ++ i) {
                ans *= 4;
                ans %= MOD;
            }
        }
        else {
            for(int i = 0; i < n; ++ i) {
                ans *= 4;
                ans %= MOD;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <stack>
#include <vector>
#include <sstream>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#define FFI freopen("in.txt", "r", stdin)
#define maxn 100010
#define INF 0x3f3f3f3f
#define inf 10000000
#define MOD 1000000007
#define ULL unsigned long long
#define LL long long
#define _setm(houge) memset(houge, INF, sizeof(houge))
#define _setf(houge) memset(houge, -1, sizeof(houge))
#define _clear(houge) memset(houge, 0, sizeof(houge))
using namespace std;

int count_(int n) {
    int cnt = 0;
    while(n) {
        if(n%2) cnt++;
        n /= 2;
    }
    return cnt;
}

int main() {
    int n;
    string s;
    while(cin >> n >> s) {
        int len = s.length();
        long long ans = 1;
        int now = 0;
        for(int i = 0; i < len; ++ i) {
            if(s[i] == 'A') now |= 1;
            else if(s[i] == 'T') now |= 2;
            else if(s[i] == 'G') now |= 4;
            else now |= 8;
        }
        int k = count_(now);
        if(k == 1) ans = 1;
        else if(k == 2) {
            for(int i = 0; i < n; ++ i) {
                ans *= 2;
                ans %= MOD;
            }
        }
        else if(k == 3) {
            for(int i = 0; i < n; ++ i) {
                ans *= 3;
                ans %= MOD;
            }
        }
        else {
            for(int i = 0; i < n; ++ i) {
                ans *= 4;
                ans %= MOD;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


# include <bits/stdc++.h>

# define ff first
# define ss second
# define mp(x,y) make_pair(x,y)
# define pb(x) push_nack(x)
# define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

template<typename A, typename B> inline void amax(A &x, B y) {if(x < y) x = y;}
template<typename A, typename B> inline void amin(A &x, B y) {if(!(x < y)) x = y;}

typedef long long lld;

using namespace std;

map<char,lld> cnt;
char s[100009];
int n;

int main(){
	scanf("%d",&n);

	scanf("%s",s);

	for(int i=0; i<n; i++)
		cnt[s[i]]++;

	lld mx = max(max(cnt['A'],cnt['C']), max(cnt['G'],cnt['T']));
	lld sany = 0;

	if(cnt['A'] == mx)
		sany++;

	if(cnt['C'] == mx)
		sany++;

	if(cnt['G'] == mx)
		sany++;

	if(cnt['T'] == mx)
		sany++;

	lld ans = 1;

	for(int i=0; i<n; i++)
		ans = (ans * sany) % 1000000007LL;

	printf("%d",ans);
}


# include <bits/stdc++.h>

# define ff first
# define ss second
# define mp(x,y) make_pair(x,y)
# define pb(x) push_nack(x)
# define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

template<typename A, typename B> inline void amax(A &x, B y) {if(x < y) x = y;}
template<typename A, typename B> inline void amin(A &x, B y) {if(!(x < y)) x = y;}

typedef long long lld;

using namespace std;

map<char,lld> cnt;
char s[100009];
int n;

int main(){
	scanf("%d",&n);

	scanf("%s",s);

	for(int i=0; i<n; i++)
		cnt[s[i]]++;

	lld mx = max(max(cnt['A'],cnt['C']), max(cnt['G'],cnt['T']));
	lld sany = 0;

	if(cnt['A'] == mx)
		sany++;

	if(cnt['C'] == mx)
		sany++;

	if(cnt['G'] == mx)
		sany++;

	if(cnt['T'] == mx)
		sany++;

	lld ans = 1;

	for(int i=0; i<n; i++)
		(ans *= sany) % 10000000007LL;

	printf("%lld",ans);
}


# include <bits/stdc++.h>

# define ff first
# define ss second
# define mp(x,y) make_pair(x,y)
# define pb(x) push_nack(x)
# define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

template<typename A, typename B> inline void amax(A &x, B y) {if(x < y) x = y;}
template<typename A, typename B> inline void amin(A &x, B y) {if(!(x < y)) x = y;}

typedef long long lld;

using namespace std;

map<char,lld> cnt;
char s[100009];
int n;

int main(){
	int e = 13;

	(e *= 5) % 20;

	printf("%d",e);

	scanf("%d",&n);

	scanf("%s",s);

	for(int i=0; i<n; i++)
		cnt[s[i]]++;

	lld mx = max(max(cnt['A'],cnt['C']), max(cnt['G'],cnt['T']));
	lld sany = 0;

	if(cnt['A'] == mx)
		sany++;

	if(cnt['C'] == mx)
		sany++;

	if(cnt['G'] == mx)
		sany++;

	if(cnt['T'] == mx)
		sany++;

	lld ans = 1;

	for(int i=0; i<n; i++)
		(ans *= sany) % 10000000007LL;

	printf("%lld",ans);
}


#include <iostream>
#include <algorithm>
using namespace std;

char buf[123456];
int table[512];
const int MOD = 1000000007;
int main()
{
   long long int N;
   cin >> N;

   int alc = 0;

   cin >> buf;
   for(int i = 0; i < N; i++)
       alc = max(alc, ++table[buf[i]]);

   cout << alc * N % MOD * N % MOD << '\n';
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

char buf[123456];
int table[512];
const int MOD = 1000000007;
int main()
{
   long long int N;
   cin >> N;

   int alc = 0;
   int num = 0;
   cin >> buf;
   for(int i = 0; i < N; i++)
   {
       int now = ++table[buf[i]];
       if(now == alc)
           num++;
       else if(alc < now)
       {
           alc = now;
           num = 1;
       }
   }

   int ans = 1;
   for(int i = 0; i < N; i++)
       ans = (ans * num) % MOD;

   cout << ans <<'\n';
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

char buf[123456];
int table[512];
const int MOD = 1000000007;
int main()
{
   long long int N;
   cin >> N;

   int alc = 0;
   long long int num = 0;
   cin >> buf;
   for(int i = 0; i < N; i++)
   {
       int now = ++table[buf[i]];
       if(now == alc)
           num++;
       else if(alc < now)
       {
           alc = now;
           num = 1;
       }
   }

   int ans = 1;
   for(int i = 0; i < N; i++)
       ans = (ans * num) % MOD;

   cout << ans <<'\n';
   return 0;
}


#include <iostream>
#include <algorithm>

#define modd 1000000007
#define maxx 100005
using namespace std;

long long mod_powr(long long a,long long b,long long m){

    if(b==0)
        return 1;

        if(b%2==0)
            return mod_powr(a*a%m,b/2,m);

        return (a*mod_powr(a,b-1,m))%m;
    }

long long ans[5],n;
int i;
char s[maxx];
int main()
{

    cin>>n>>s;

    for(i=0;i<n;i++){
        if(s[i]=='A')
            ans[0]++;
        else
            if(s[i]=='C')
            ans[1]++;
        else
            if(s[i]=='G')
            ans[2]++;
        else
            ans[3]++;
    }

    sort(ans,ans+4);

    i=2;
    long long cnt=1;
    while(ans[i]==ans[3] && i>=0)
    {
        cnt++;
        i--;
    }

    cout << mod_powr(cnt,n,modd) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>

#define modd 1000000007
#define maxx 100005
using namespace std;

long long mod_powr(long long a,long long b,long long m){

    if(b==0)
        return 1;
    if(b==1)
        return a;
        if(b%2==0)
            return (mod_powr((a*a)%m,b/2,m));

        else
        return ((a*mod_powr(a,b-1,m))%m);
    }

long long ans[5],n;
int i;
char s[maxx];
int main()
{

    cin>>n>>s;

    for(i=0;i<n;i++){
        if(s[i]=='A')
            ans[0]++;
        else
            if(s[i]=='C')
            ans[1]++;
        else
            if(s[i]=='G')
            ans[2]++;
        else
            if(s[i]=='T')
            ans[3]++;
    }

    sort(ans,ans+4);

    i=2;
    long long cnt=1;
    while(ans[i]==ans[3] && i>=0)
    {
        cnt++;
        i--;
    }

    cout << mod_powr(cnt,n,modd) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>

#define modd 1000000007
#define maxx 100005
using namespace std;

long long mod_powr(long long a,long long b,long long m){

    if(b==0)
        return 1;
    if(b==1)
        return a;
        if(b%2==0)
            return (mod_powr((a*a)%m,b/2,m));

        else
        return ((a*mod_powr(a,b-1,m))%m);
    }

long long ans[5],n;
int i;
char s[maxx];
int main()
{

    cin>>n>>s;

    for(i=0;i<n;i++){
        if(s[i]=='A')
            ans[0]++;
        else
            if(s[i]=='C')
            ans[1]++;
        else
            if(s[i]=='G')
            ans[2]++;
        else
            if(s[i]=='T')
            ans[3]++;
    }

    sort(ans,ans+4);

    i=2;
    long long cnt=1;
    while(i>=0 && ans[i]==ans[3])
    {
        cnt++;
        i--;
    }

    cout << mod_powr(cnt,n,modd) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#define maxx 100005
using namespace std;

long long mod_powr(long long a,long long b,long long m){

    if(b==0)
        return 1;
    if(b==1)
        return a;
        if(b%2==0)
            return (mod_powr((a*a)%m,b/2,m));

        else
        return ((a*mod_powr(a,b-1,m))%m);
    }

long long ans[30],n;
int i;
char s[maxx];
int main()
{

    cin>>n>>s;

    for(i=0;i<n;i++)
            ans[(int)s[i]-65]++;

    sort(ans,ans+26);

    i=24;
    long long cnt=1;
    while(ans[i]==ans[25] && i>=0)
    {
        cnt++;
        i--;
    }
    long long modd =1000000007;
    cout << mod_powr(cnt,n,modd) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>

#define modd 1000000007
#define maxx 100005
using namespace std;

long long mod_powr(long long a,long long b,long long m){

    if(b==0)
        return 1;
    if(b==1)
        return a;
        if(b%2==0)
            return (mod_powr((a*a)%m,b/2,m));

        else
        return ((a*mod_powr(a,b-1,m))%m);
    }

long long ans[6],n;
int i;
char s[maxx];
int main()
{

    cin>>n>>s;

    for(i=0;i<n;i++){
        if(s[i]=='A')
            ans[0]++;
        else
            if(s[i]=='C')
            ans[1]++;
        else
            if(s[i]=='G')
            ans[2]++;
        else
            if(s[i]=='T')
            ans[3]++;
    }

    sort(ans,ans+5);

    i=3;
    long long cnt=1;
    while(ans[i]==ans[4] && i>0)
    {
        cnt++;
        i--;
    }

    cout << mod_powr(cnt,n,modd) << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
int main()
{ios_base::sync_with_stdio(false);
ll n;string s;ll m=1e9+7,idx=0,f=0,f1=0,ans=0;
gl(n);set<char> a;
cin>>s;
rep(i,1,n-1)
{
    if(s[i]!=s[0])
    {
        f1=1;break;
    }
}
if(f1==0||n==1)
{
     //ans=(n*n)%m;
    //ans=(ans*n)%m;
    ol("1");
    return 0;
}
rep(i,0,n-1)
{
    a.insert(s[i]);
}
/*if(s[0]!=s[n-1])
{
idx=0;
f=1;
}
if(f==0)
{
    rep(i,1,n-1)
    {
        if(s[i]!=s[i-1])
        {
            idx=i;
            break;
        }
    }
}
int j=idx;ll c=1;
do
{
    if(s[j]==s[(j-1+n)%n])
    {
        c++;
    }
    else
    {
        //ol(c);on;
        ans=(ans+(((c*c)%m)*n)%m)%m;
        //ol(ans);on;
        c=1;
    }
    j=(j+1)%n;
}while(idx!=j);
ol(ans%m);*/
rep(i,0,n-1)
{
    if(s[i]!=s[(i-1+n)%n]&&s[i]!=s[(i+1)%n])
    {
        ans=(ans+a.size()-1)%m;
        //ol(ans);on;
        //ol(s[i]);on;
    }
}
ol((ans+n)%m);on;
return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
ll m=1e9+7;

ll p(ll a,ll b)
{
    ll r=1;
    while(b>0)
    {
        if(b&1)
        r=(r*a)%m;
        a=(a*a)%m;
        b/=2;
    }
    return r;
}
int main()
{ios_base::sync_with_stdio(false);
int n;ll c[4]={0};
gl(n);
string s;cin>>s;
rep(i,0,n-1)
{
    if(s[i]=='A')c[0]++;
    else if(s[i]=='G')c[1]++;
    else if(s[i]=='C')c[2]++;
    else c[3]++;
}
sort(c,c+4);
ll ans=0;
rep(i,0,3)
if(c[i]==c[3])ans++;
ol(p(ans,n));
return 0;
}