R=raw_input o=set(R()) while 1: l=R() if set(l)==o:print l