R=raw_input s=R() while 1: t=R() if set(t)==set(s):print t