r=raw_input a=set(r()) while 1: i=r() if a==set(i):print i