b=raw_input() n=input() a=raw_input() t=set([b]) for i in xrange(min(n,100)): u=set() for j in t: l=list(j) u.add("".join([l[1],l[0],l[2]])) u.add("".join([l[0],l[2],l[1]])) t=u #print t print["SUCCESS","FAILURE"][a in t]