#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long int n;
    cin >> n;
    char title[n];

    unordered_map<char, int> occurrences {{'A', 0}, {'B', 0}, {'C', 0}, {'D', 0}, {'E', 0}, {'F', 0}, {'G', 0}, {'H', 0},
        {'I', 0}, {'J', 0}, {'K', 0}, {'L', 0}, {'M', 0}, {'N', 0}, {'O', 0}, {'P', 0}, {'Q', 0}, {'R', 0}, {'S', 0}, {'T', 0},
        {'U', 0}, {'V', 0} , {'W', 0}, {'X', 0}, {'Y', 0}, {'Z', 0}};

    char last_char = ' ';
    for(int i = 0; i < n; i++)
    {
        cin >> title[i];
        if (title[i] >= last_char)
        {
            last_char = title[i];
            occurrences[last_char]++;
        }
    }

    long long total = 1;
    for(const auto &pair : occurrences)
    {
        cout << pair.first << " " << pair.second << endl;
        total *= pair.second;
    }

    cout << total % 1000000007;

    return 0;
}