S = input() E = S.find('OOO') W = S.find('XXX') if E == -1: E = 99 if W == -1: W = 99 print('NA' if E == W == 99 else ['West', 'East'][E < W])