#INPUT#
allinputs = [int(l) for l in input().split()]
enemy = allinputs[:3]
marker = allinputs[3]
dice = []
for l in range(allinputs[4]):
  dice.append(allinputs[5 + l])
  
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
square = [9,16,25,36,49]
corners = [7,12,17,22,27,35,40,45,50]
possible = []

#RULES#
def turn(marker, roll):
#  for i in range(roll):
#    possible.append(marker)
#    marker += 1
  marker += roll

  possible = list(range(marker - roll,marker + 1))
  if marker in enemy:
    marker -= roll
    return marker
  if marker == 52:
    return marker
  if marker > 52:
    marker -= roll


  if marker in prime:
    if marker + 6 <= 52 or max(enemy) > marker:
      for i in range(6):
        marker += 1
        if marker in enemy:
          marker -= 1
          return marker
      return marker

  if marker in square:
    for j in range(6):
      marker -= 1
      if marker in enemy:
        marker += 1
        return marker
    return marker

  for m in range(len(corners)):
    if possible[0] < corners[m] < possible[len(possible) - 1]:
      for p in range(len(possible) - 1,0,-1):
        if possible[p] % roll == 0 and possible[p] not in enemy and possible[p] <= 52:
          marker = possible[p]
          return marker
      marker -= roll

  return marker

#DRIVER#
for q in range(allinputs[4]):
  marker = turn(marker,dice[0])
  if marker == 52:
    print("GAME OVER")
    break
  dice.pop(0)
  possible.clear()
if marker != 52:
  print(marker)