data = [input() for i in range(4)]
print("Yes" if (("*" +'*'.join(data[3].split()) + "*") in ('*'.join(data[1].split()*2))) else "No")