#include<iostream>
using namespace std;
int main(){
long long n1, n2, k, vhod, izhod, A, B, barrel, barel;
char c1,c2;
cin>>n1>>c1;
cin>>n2>>c2;
cin>>k;
vhod=k-n1;
izhod=k-vhod;
if(c1='A'){
    barrel=k-n1;
}
if(c1='B'){
    barrel=k-n2;
}
if(c2='A'){
    barel=k-n1;
}
if(c2='B'){
    barel=k-n2;
}



cout<<"\n";

cout<<n1<<" "<<c1<<"\n"<<n2<<" "<<c2<<"\n"<<k<<"\n"<<izhod;
return 0;
}