eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Octagons

Octagons

Below is a picture of an infinite hyperbolic tessellation of octagons. If we think of this as a graph of vertices (of degree three), then there exists an isomorphism of the graph which maps any vertex \textbf{x} onto any other vertex \textbf{y}. Every edge is given a label from the set \textbf{\{a,b,c\}} in such a way that every vertex has all three types of edges incident on it, and the labels alternate around each octagon. Part of this labeling is illustrated in the diagram. \includegraphics{https://static.e-olymp.com/content/d1/d1e2a032b40cc91b3c9a37b1fcb563a8383f102e.jpg} So a path in this graph (starting from any vertex) can be specified by a sequence of edge labels. Your job is to write a program which, given a squence of labels such as "\textbf{abcbcbcabcaccabb}", returns "\textbf{closed}" if the path ends on the same vertex where it starts, and returns "\textbf{open}" otherwise. \InputFile The input will begin with a number \textbf{Z} ≤ \textbf{200} on a line by itself. This is followed by \textbf{Z} lines, each of which is a squence of length at least \textbf{1} and at most \textbf{40} of '\textbf{a}'s '\textbf{b}'s and '\textbf{c}'s. \OutputFile For each input instance, the output will be the words "\textbf{closed}" or "\textbf{open}", each on a single line.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
abababab
abcbcbcbcba
Вихідні дані #1
closed
open