// Arup Guha
// 8/21/2026
// Solution to 2026 UCF Locals Problem: Letter Pairs

using namespace std;
#include <bits/stdc++.h>

int main() {

    // Set up frequency arrays and array of max values for each.
    vector<vector<int>> after(26, vector<int>(26, 0));
    vector<int> maxF(26, 0);
    vector<bool> used(26, false);

    // Read the whole line.
    string line;
    getline(cin, line);

    for (int i=0; i<line.size(); i++) {

        // No processing here.
        char b = line[i];
        if (b<'a' || b>'z') continue;

        // To make sure I mark all letters in the string.
        used[b-'a'] = true;

        // So I don't crash.
        if (i == line.size()-1) break;

        // Next letter.
        char c = line[i+1];

        // So I don't crash.
        if (c<'a' || c>'z') continue;

        // Only time we process.
        if (b>='a' && b<='z') {
            after[b-'a'][c-'a']++;
            maxF[b-'a'] = max(maxF[b-'a'], after[b-'a'][c-'a']);
        }
    }

    // Go through all letters.
    for (int i=0; i<26; i++) {

        // Letter not in string.
        if (!used[i]) continue;

        // Line header.
        cout << (char)('a'+i) << ":";

        // Case with nothing following...
        if (maxF[i] == 0)
            cout << " ?" << endl;

        // Now get most frequent follwers.
        else {

            // See which letters are of the max frequency.
            for (int j=0; j<26; j++)
                if (after[i][j] == maxF[i])
                    cout << " " << char('a'+j);
            cout << endl;
        }
    }

    return 0;
}
