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