//我自己sb 在dfs回去的时候少加了几个return 导致tle 就有点气
// 题目就不列了 就是暴力dfs 很easy 作为一个新手也可以自己码出来
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double n;
int sz;
double sum;
int word[13];
bool mark[13];
int ans[6];
bool flag;
bool cmp(int a, int b) {
return a > b;
}
void dfs(int k) {
if (!flag) return;
if (k > 5) {
//cout << sum << " ";
sum = ans[1] - ans[2] * ans[2] + ans[3] * ans[3] * ans[3] - ans[4] * ans[4] * ans[4] * ans[4] + ans[5] * ans[5] * ans[5] * ans[5] * ans[5];
if (sum == n) {
for (int i = 1; i <= 5; i++) {
// cout << ans[i] << endl;
char x = ans[i] + 'A' -1;
cout << x;
}
cout << endl;
flag = 0;
}
return;
}
for (int i = 1; i <= sz; i++) {
if (!mark[i]) {
mark[i] = 1;
ans[k] = word[i];
dfs(k + 1);
mark[i] = 0;
}
}
}
int main()
{
string s;
while (cin >> n) {
flag = 1;
cin >> s;
memset(mark, 0, sizeof(mark));
memset(ans, 0, sizeof(ans));
memset(word, 0, sizeof(word));
if (s == "END") break;
sz = s.size();
for (int i = 0; i < sz; i++) {
word[i + 1] = s[i] - 'A' + 1;
}
sort(word+1, word+sz+1,cmp);
// for (int i = 1; i <= sz; i++)
// cout << word[i] << " ";
dfs(1);
if (flag) cout << "no solution" << endl;
}
return 0;
}