#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
bool isnum(char c){
    return '0'<=c&&c<='9';
}
bool iszm(char c){
    return 'a'<=c&&c<='z';
}
bool isdazm(char c){
    return 'A'<=c&&c<='Z';
}
string js(int p1,int p2,int p3,char st,char end){
    string apps="";
    
    if(st>=end){
        return "-";
    }else if((isnum(st)&&isnum(end))||(iszm(st)&&iszm(end))||(isdazm(st)&&isdazm(end))){
     
    if(p1==1){
         for(char s=st+1;s!=end;s++){
        apps.append(p2,s);
      }
    }else if(p1==2){
         for(char s=st+1;s!=end;s++){
        apps.append(p2,toupper(s));
      }
    }else{
         for(char s=st+1;s!=end;s++){
        apps.append(p2,'*');
      }
    }
     if(p3==2){
        reverse(apps.begin(), apps.end());
     }
     return apps;
    }else{
        return "-";
    }


   
}
int main() {
   int p1,p2,p3;
   cin>>p1>>p2>>p3;
   string ans;
   cin>>ans;
   string jg;
   for(int i=0;i<ans.size();i++)
   {
    if(ans[i]!='-'){
        jg+=ans[i];
    }else{
        jg+=js(p1,p2,p3,ans[i-1],ans[i+1]);
    }
   }
   cout<<jg<<endl;
}
// 64 位输出请用 printf("%lld")