#include using namespace std; struct frequency { int f; char l; frequency() { f = 0; } }; frequency f[26]; char t[3][10]; int pos[3][10] = {0}; int m[3] = {10, 9, 7}; void init() { for (int i = 0; i < 26; i ++) { f[i].l = i + 'a'; } for (int i = 0; i < 3; i ++) { for (int j = 0; j < 10; j ++) { t[i][j] = '0'; } } } bool cmp(frequency a, frequency b) { return a.f > b.f; } int main() { freopen("keyboard.out","w",stdout); init(); int n, rfr, rfc, lfr, lfc; string s; cin >> n; cin >> s; for (int i = 0; i < n; ++ i) { f[s[i] - 'a'].f ++; } sort(f, f + 26, cmp); int rr, cr, rl, cl; rr = 1; cr = 6; rl = 1; cl = 4; int p = 2; t[rl][cl] = f[0].l; pos[rr][cr] = 1; bool ok; int h = 1; // // for(int i = 0; i < 26; i ++) // cout << f[i].l << " "; // // cout << endl; do { ok = false; for (int i = 0; i < 3; i ++) { for (int j = 0; j < m[i]; j ++) { if (pos[i][j] == p - 1) { if (i + 1 < 3 && t[i+1][j] == '0' && j < m[i+1]) { pos[i+1][j] = p; t[i+1][j] = f[h].l; h ++; ok = 1; } if (i - 1 >= 0 && t[i-1][j] == '0' && j < m[i-1]) { pos[i-1][j] = p; t[i-1][j] = f[h].l; h ++; ok = 1; } if (j + 1 < m[i] && t[i][j+1] == '0') { pos[i][j+1] = p; t[i][j+1] = f[h].l; h ++; ok = 1; } if (j - 1 >= 0 && t[i][j-1] == '0') { pos[i][j-1] = p; t[i][j-1] = f[h].l; h ++; ok = 1; } // cout << h << endl; // // for (int i = 0; i < 10; i ++) // cout << t[0][i]; // cout << endl; // for (int i = 0; i < 10; i ++) // cout << t[1][i]; // cout << endl; // for (int i = 0; i < 10; i ++) // cout << t[2][i]; // // cout << endl << endl << endl; } } } p ++; } while(ok); for (int i = 0; i < 10; i ++) cout << t[0][i]; for (int i = 0; i < 9; i ++) cout << t[1][i]; for (int i = 0; i < 7; i ++) cout << t[2][i]; cout << endl; int st, fn, tmp; tmp = 0; while (1) { tmp ++; if (tmp == n || s[tmp] != s[0]) break; } if (tmp >= n) fn = 15; for (int i = 0; i < 10; i ++) { if (t[0][i] == s[0]) st = i + 1; if (t[0][i] == s[tmp] && tmp < n) fn = i + 1; } for (int i = 0; i < 9; i ++) { if (t[1][i] == s[0]) st = i + 11; if (t[1][i] == s[tmp] && tmp < n) fn = i + 11; } for (int i = 0; i < 7; i ++) { if (t[2][i] == s[0]) st = i + 20; if (t[2][i] == s[tmp] && tmp < n) fn = i + 20; } if (fn != st) cout << st << " " << fn << endl; else cout << st << " " << 14 << endl; fclose(stdout); return 0; }