#include<stdio.h>
#include<string.h>
int main()
{
int a[3],j,i,t;
char str;
scanf("%d %d %d\n%s",&a[0],&a[1],&a[2],&str);
for(j=0;j<2;j++)//排序让a[2]对应C,a[2]对应B,让a[0]对应A
for(i=0;i<2-j;i++)
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
if(strcmp(str,"ABC")==0)
printf("%d %d %d\n",a[0],a[1],a[2]);
if(strcmp(str,"ACB")==0)
printf("%d %d %d\n",a[0],a[2],a[1]);
if(strcmp(str,"CBA")==0)
printf("%d %d %d\n",a[2],a[1],a[0]);
if(strcmp(str,"CAB")==0)
printf("%d %d %d\n",a[2],a[0],a[1]);
if(strcmp(str,"BAC")==0)
printf("%d %d %d\n",a[1],a[0],a[2]);
if(strcmp(str,"BCA")==0)
printf("%d %d %d\n",a[1],a[2],a[0]);
return 0;
}