Under construction

Still being built. Things may change

Tautogram

Interview

Time limit1sMemory limit128 MB

Summary
For each sentence, decide whether every word begins with the same letter, ignoring case, until a line containing only *.
Level

Easy3 of 10

Topics
String, Implementation, Brute force
Solved
No attempts yet

Problem

Seonyeong loves poetry. While reading a poetry collection recently, she came across a very charming poetic form. A tautogram is a special kind of alliteration in which every word of a sentence begins with the same letter.

In other words, a sentence is a tautogram if and only if all of its words start with the same letter. The comparison is case-insensitive.

For example, the following sentences are all tautograms:

  • Flowers Flourish from France
  • Sam Simmonds speaks softly
  • Peter pIckEd pePPers
  • truly tautograms triumph

Seonyeong wants to use tautograms to write a love letter. Given one sentence from her letter, write a program that determines whether it is a tautogram.

Input

The input consists of several test cases. Each test case is a single line corresponding to one sentence of the letter.

Each sentence contains at most 50 words separated by single spaces. Each word consists only of uppercase and lowercase letters and has length at most 20.

Every word contains at least one letter, and every sentence contains at least one word.

The line following the last test case contains a single character *, marking the end of the input.

Output

For each test case, print Y on its own line if the given sentence is a tautogram, or N otherwise.

Examples1

  1. Example 1

    Input
    Flowers Flourish from France
    Sam Simmonds speaks softly
    Peter pIckEd pePPers
    truly tautograms triumph
    this is NOT a tautogram
    *
    
    Expected output
    Y
    Y
    Y
    Y
    N