#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int p1,p2,p3;
string f = "";
void tian(char a,char b){
if(a == b || a > b){
f = "-";
return ;
}
if(a <= '9' && a >= '0' && b <= 'z' && b >= 'a'){
f = "-";
return ;
}
if(b <= '9' && b >= '0' && a <= 'z' && a >= 'a'){
f = "-";
return ;
}
for(char i = a + 1;i <= b - 1;i++){
for(int j = 1;j <= p2;j++){
if(p1 == 1){
f += i;
}
else if(p1 == 2){
if(i <= '9' && i >= '0'){
f += i;
}
else{
f += i - ('a' - 'A');
}
}
else{
f += '*';
}
}
}
if(p3 == 2){
reverse(f.begin(),f.end());
}
}
int main(){
char a,b;
string t,s = "";
cin>>p1>>p2>>p3;
cin>>t;
for(int i = 0;i < t.size();i++){
if(t[i] != '-'){
a = t[i];
s += t[i];
}
else{
b = t[i + 1];
tian(a,b);
s += f;
f = "";
}
}
cout<<s<<endl;
return 0;
}