a=gets.scan(/X{3}|O{3}/) puts a.empty? ? "NA" : a[0] == "OOO" ? "East" : "West"