cf#99 C. Literature Lesson
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u"are considered vowels.
Two lines rhyme if their suffixes that start from the k-th vowels (counting from the end) match. If a line has less than kvowels, then such line can't rhyme with any other line. For example, if k = 1, lines commit and hermit rhyme (the corresponding suffixes equal it), and if k = 2, they do not rhyme (ommit ≠ ermit).
Today on a literature lesson Vera learned that quatrains can contain four different schemes of rhymes, namely the following ones (the same letters stand for rhyming lines):
Clerihew (aabb);
Alternating (abab);
Enclosed (abba).
If all lines of a quatrain pairwise rhyme, then the quatrain can belong to any rhyme scheme (this situation is represented by aaaa).
If all quatrains of a poem belong to the same rhyme scheme, then we can assume that the whole poem belongs to this rhyme scheme. If in each quatrain all lines pairwise rhyme, then the rhyme scheme of the poem is aaaa. Let us note that it doesn't matter whether lines from different quatrains rhyme with each other or not. In other words, it is possible that different quatrains aren't connected by a rhyme.
Vera got a long poem as a home task. The girl has to analyse it and find the poem rhyme scheme. Help Vera cope with the task.
Input
The first line contains two integers n and k (1 ≤ n ≤ 2500, 1 ≤ k ≤ 5) — the number of quatrains in the poem and the vowel's number, correspondingly. Next 4n lines contain the poem. Each line is not empty and only consists of small Latin letters. The total length of the lines does not exceed 104.
If we assume that the lines are numbered starting from 1, then the first quatrain contains lines number 1, 2, 3, 4; the second one contains lines number 5, 6, 7, 8; and so on.
Output
Print the rhyme scheme of the poem as "aabb", "abab", "abba", "aaaa"; or "NO"if the poem does not belong to any of the above mentioned schemes.
Sample test(s)
input
1 1
day
may
sun
fun
output
aabb
input
1 1
day
may
gray
way
output
aaaa
input
2 1
a
a
a
a
a
a
e
e
output
aabb
input
2 1
day
may
sun
fun
test
hill
fest
thrill
output
NO
Note
In the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".
#include
파이팅!잘 될 거라고 믿어, 다 잘 될 거야.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
html 버전 SICP를 kindle에서 읽을 수 있도록 시도했습니다.최근, 여러가지 번역의 전자서적판이 나돌고 있습니다만 아무도 이마이치이므로, 와다 선생님의 번역을 간편하게 읽을 수 있도록(듯이) 하고 싶었습니다. 또, 전자 서적판이라고 말해 두면서 리플로우도 없고 문자 사이즈의 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.