Rhyme Pattern

Interview

Time limit1sMemory limit128 MB

Summary
Given verses of four lines, extract each line's last syllable from its final word and classify the rhyme pattern as perfect, even, cross, shell, or free.
Level

Easy3 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

A song consists of one or more verses, and each verse consists of four lines. Each line consists of one or more words separated by a single space. Each word consists only of uppercase and lowercase English letters (a-z, A-Z).

The rhyme of a line is determined by the last word of that line. In this problem, the vowels are a, e, i, o, and u. The last syllable of a word is the substring from the last vowel in the word through the end of the word. If the word has no vowel, the whole word is its last syllable. Last syllables are compared case-insensitively.

Two lines rhyme when their last syllables are equal. The four lines of a verse are classified into one of the following five patterns.

  • perfect: all four lines rhyme with one another (a a a a)
  • even: not perfect, and line 1 rhymes with line 2 while line 3 rhymes with line 4 (a a b b)
  • cross: not perfect, and line 1 rhymes with line 3 while line 2 rhymes with line 4 (a b a b)
  • shell: not perfect, and line 1 rhymes with line 4 while line 2 rhymes with line 3 (a b b a)
  • free: none of the above patterns applies

Write a program that determines the rhyme pattern of each verse.

Input

The first line contains an integer N, the number of verses in the song. (1 <= N <= 5)

The next 4N lines contain the lines of the song in order. The maximum length of each line is 50.

Output

Print one line for each verse. Each line must contain one of perfect, even, cross, shell, or free, describing that verse's rhyme pattern.

Examples1

  1. Example 1

    Input
    1
    mi smo Super
    Edit Pjaf Ran
    gari geri kuper
    ej pazi na ekran
    
    Expected output
    cross