CF138A.Literature Lesson

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 kk -th vowels (counting from the end) match. If a line has less than kk vowels, then such line can't rhyme with any other line. For example, if k=1k=1 , lines commitcommit and hermithermit rhyme (the corresponding suffixes equal itit ), and if k=2k=2 , they do not rhyme ( ommitermitommit≠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 ( aabbaabb );
  • Alternating ( abababab );
  • Enclosed ( abbaabba ).

If all lines of a quatrain pairwise rhyme, then the quatrain can belong to any rhyme scheme (this situation is represented by aaaaaaaa ).

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 aaaaaaaa . 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.

输入格式

The first line contains two integers nn and kk ( 1<=n<=25001<=n<=2500 , 1<=k<=51<=k<=5 ) — the number of quatrains in the poem and the vowel's number, correspondingly. Next 4n4n 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 10410^{4} .

If we assume that the lines are numbered starting from 1, then the first quatrain contains lines number 11 , 22 , 33 , 44 ; the second one contains lines number 55 , 66 , 77 , 88 ; and so on.

输出格式

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.

输入输出样例

  • 输入#1

    1 1
    day
    may
    sun
    fun
    

    输出#1

    aabb
    
  • 输入#2

    1 1
    day
    may
    gray
    way
    

    输出#2

    aaaa
    
  • 输入#3

    2 1
    a
    a
    a
    a
    a
    a
    e
    e
    

    输出#3

    aabb
    
  • 输入#4

    2 1
    day
    may
    sun
    fun
    test
    hill
    fest
    thrill
    

    输出#4

    NO
    

说明/提示

In the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".

首页