program main implicit none character*100::S character*3,parameter::e="OOO",w="XXX" integer::i read *,S do i=1,LEN_TRIM(S)-2 if(S(i:i+2).eq.e) then print '(a)',"East" return else if(S(i:i+2).eq.w) then print '(a)',"West" return end if end do print '(a)',"NA" end program main