let () = let s = stdin.ReadLine() let maru = s.IndexOf("OOO") let batu = s.IndexOf("XXX") let ans = if maru = -1 && batu = -1 then "NA" elif maru = -1 then "West" elif batu = -1 then "East" elif maru < batu then "East" else "West" printfn "%s" ans