array = input().split(' ')
for x in range(len(array)):
    array[x] = int(array[x])
opponents = array[0:3]
you = array[3]
dice = array[5:len(array)]
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
squares = [9, 16, 25, 36, 49]
turnsquares = [7, 12, 17, 22, 27, 35, 40, 45, 50]
flag = True
for x in range(array[4]):
    you1 = you
    you += dice[x]
    if you > 52:
        you -= dice[x]
    elif you == 52:
        print('GAME OVER')
        flag = False
        break
    elif you in opponents:
        you -= dice[x]
    elif you in primes:
        for a in range(6):
            you += 1
            if you in opponents:
                you -= 1
                break
    elif you in squares:
        for a in range(6):
            you -= 1
            if you in opponents:
                you += 1
                break
    else:
        for y in turnsquares:
            if y > you - dice[x] and y < you:
                for z in range(dice[x]):
                    if (you - z)/dice[x] == int((you - z)/dice[x]):
                        for a in range(z):
                            you -= 1
                            if you in opponents:
                                you = you1
                                break
if flag:
    print(you)