for _ in range(7):
	s,x=input();r='';q=1
	for c in zip(*[t for t in x if s<=t<s+'ÿ']):q/=len(set(c));r+=c[0]*q
	print r or s