by@kcz146
WA
849ms
a,*b,c=open(0) i=a.find("T") x=a*3 d=c.rstrip()+"*"*i print(x+d[:i+1])
T K
T T T K*********************