initial = input().split()
target = input().split()
T = int(input())
target_pos = {color: i for i, color in enumerate(target)}
arr = [target_pos[color] for color in initial]
swaps = 0
n = len(arr)
for i in range(n):
for j in range(n - 1 - i):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
swaps += 1
total_time = swaps * T
status = "YES" if total_time <= 120 else "NO"
print(swaps, total_time, status)