ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Open Ural FU Championship 2011

About     Problems     Submit solution     Judge status     Standings
Contest is over

E. Poetic Foot

Time limit: 1.0 second
Memory limit: 64 MB
And telling trochee from iambic
Was quite beyond his wit, we found.

A. S. Pushkin
A poetic foot is a sequence of syllables one of which is stressed. The type of foot is determined by the number of syllables in it and by the position of the stressed syllable. A disyllabic foot is called a trochee if the first syllable is stressed and an iamb if the second syllable is stressed. A trisyllabic foot is called a dactyl, amphibrach, or anapaest if the first, second, or third syllable is stressed, respectively.
Usually, each line of a poem consists of several feet, but the last foot in a line may be shortened to the first one or two syllables. All the feet in a poem must be of the same type.
School students are often asked to determine the meter (or a rhythmical structure) of a poem in their literature classes. The first step in finding the meter is to determine the type of foot used in the poem. You can help students by automating this process.


The first line contains the number of lines in a poem n (2 ≤ n ≤ 100). The poem is given in the following n lines. Each word of the poem consists of one or more syllables. If there are several syllables in a word, they are separated by a hyphen. Each stressed syllable is enclosed in square brackets. It is guaranteed that there are at least four syllables in each line of the poem. We have deleted all punctuation marks from the text, and now it contains only uppercase and lowercase English letters, spaces, hyphens, and square brackets. The length of each line is at most 50 symbols.


Output the type of foot used in the poem: “trochee”, “iamb”, “dactyl”, “amphibrach”, or “anapaest”. If the type of foot cannot be determined, output “not a poem”.


My [un]-cle [high] i-[deals] ins-[pire] him
But [when] past [jo]-king [he] fell [sick]
he [real]-ly [forced] one [to] ad-[mire] him
and [ne]-ver [played] a [shrew]-der [trick]
Problem Author: Alex Samsonov
Problem Source: Open Ural FU Championship 2011
To submit the solution for this problem go to the Problem set: 1866. Poetic Foot