h = {
    'A' => %w(B D),
    'B' => %w(A C E),
    'C' => %w(B F),
    'D' => %w(A E G),
    'E' => %w(B D F H),
    'F' => %w(C E I),
    'G' => %w(D H),
    'H' => %w(E G I),
    'I' => %w(F H),
}
1000.times do
    s = gets.chomp
    puts s if s.each_char.each_cons(2).all? {|x, y| h[x].include?(y)}
end
