import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); String line = stdin.nextLine(); int east = line.indexOf("OOO"); int west = line.indexOf("XXX"); if (east == -1 && west == -1) { System.out.println("NA"); } else if (east < west) { System.out.println("East"); } else { System.out.println("West"); } } }