$count = 0
$flag = true
$answer = ""


def get_answer(ans)
	$answer = ans
	$flag = false
end

def reset
	$count = 0
	puts $answer
	$answer = ""
	$flag = true
end

while gets
	line = $_.chomp
	$count += 1
	reset if $count == 8
	next if !(i1 = line.index("1")) || !$flag
	l2 = gets.chomp
	l3 = gets.chomp
	$count += 2
	if !(i2 = l2.index("1"))
		get_answer("C")
		next
	elsif line[i1] == line[i1+1] && i1 == i2
		get_answer("A")
		next
	elsif line[i1] == line[i1+1] && i1 < i2
		get_answer("E")
		next
	elsif line[i1] == line[i1+1] && i2 < i1
		get_answer("G")
		next
	elsif line[i1] != line[i1+1] && line[i2] != line[i2+1]
		get_answer("B")
		next
	elsif (i3 = l3.index("1")) == i2
		get_answer("D")
		next
	elsif i2 < i3
		get_answer("F")
		next
	end