#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int a[3];
for (int i = 0; i < 3; i++)
{
cin >> a[i];
}
sort(a, a + 3);
string t;
cin >> t;
int npa = t.find_first_of("A");
int npb = t.find_first_of("B");
int npc = t.find_first_of("C");
int r1,r2,r3;
r1 = npa == 0 ? a[0] : npb == 0 ? a[1] : a[2];
r2 = npa == 1 ? a[0] : npb == 1 ? a[1] : a[2];
r3 = npa == 2 ? a[0] : npb == 2 ? a[1] : a[2];
cout << r1 << " " << r2 << " " << r3;
return 0;
}