s = gets.chomp if s.index(/XXX/).nil? && s.index(/OOO/).nil? puts "NA" elsif s.index(/XXX/) > s.index(/OOO/) puts "East" else puts "West" end