m = {}
m["A"]="BD"
m["B"]="ACE"
m["C"]="BF"
m["D"]="AEG"
m["E"]="BDFH"
m["F"]="CEI"
m["G"]="DH"
m["H"]="EGI"
m["I"]="FH"

1000.times do
  s = gets.to_s
  flag=true
  for i in 0..s.size-3
    t=m[s[i]]
    ck=false
    for j in 0..t.size-1
      ck=true if t[j]==s[i+1]
    end
    flag=false if ck==false
  end
  puts s if flag
end
