S = gets.chomp r1 = S =~ /OOO/ || Float::INFINITY r2 = S =~ /XXX/ || Float::INFINITY if r1 < r2 puts 'East' elsif r1 > r2 puts 'West' else puts 'NA' end