def detect(fig)
	i, j = fig.first
	if fig[1] == [i, j + 1]
		case fig[2]
		when [i + 1, j]; return 'A'
		when [i, j + 2]; return 'C'
		when [i + 1, j + 1]; return 'E'
		else return 'G'
		end
	else
		case fig[2]
		when [i + 2, j]; return 'B'
		when [i + 1, j]; return 'D'
		else return 'F'
		end
	end
end

until $<.closed? or $<.eof? do
	fig = []
	$<.each_line.take(8).each_with_index do |line, i|
		line.each_char.with_index do |c, j|
			fig << [i, j] if c == '1'
		end
	end
	$<.gets

	puts detect(fig)
end