Hide

Problem I
Flower Bracelets

/problems/vths21.flowerbracelets/file/statement/en/img-0001.png
Several well-formed Flower Bracelets

Flora likes to make virtual flower bracelets in her spare time. The bracelets are made of six different kinds of pieces: butterfly, daisy, sunflower, rose, hibiscus, and clover. While each flower bracelet is unique, their design follows a set of rules, which is shown below:

\includegraphics[width=0.4\textwidth ]{grammar3.png}

Figure 1: Rules for well-formed flower bracelets

The rules must be read left to right, and the | symbol denotes “or” when $2$ or more choices can apply.

Counterfeit bracelets, however, do not follow these rules.

Write a program to distinguish authentic flower bracelets from counterfeit ones!

To simplify your task, we will represent bracelet pieces using lowercase letters according to the following key:

\includegraphics[width=0.4\textwidth ]{allflowers3x2.png}

Input

The input consists of multiple test cases. The first line contains an integer $n$ ($1 \le n \le 100$) denoting the number of test cases. This is followed by $n$ lines, each containing a string $s$ of between $1$ and $100$ English lowercase characters.

Output

Output $n$ lines containing either authentic or counterfeit depending on whether the $i^\texttt {th}$ given string represents an authentic bracelet or not.

Sample Input 1 Sample Output 1
12
bssddssdrrrhdddcc
brssdssddddhdddddcc
brrssrssdrdhddcc
bssdrrrdddhddddcc
bdssdddrrrhddddcc
bdssdssssrrhddcc
bdssrdddddhddddddcc
bssdssssddsshdddcc
brrssdssssrsshdcc
bdrssssssrsshdcc
bdssssssrrdsshddcc
bddrdrrdsshddddcc
authentic
authentic
authentic
authentic
authentic
authentic
authentic
authentic
authentic
authentic
authentic
authentic
Sample Input 2 Sample Output 2
13
bssdssdrrrhdddcc
brssdssddhddhdddddcc
brrssrssdrddhdcc
bssdrrddddhddddcc
bdsdsddrrrrhddddcc
bdssdshhsssrrhddcc
bssdssddssddsshdddcc
brresdssssrsshdcc
brdsrhhsssssrsshdcc
bdssssrrdsshdcc
ddrdrrdsshddddcc
brrssdssssrsshdc
brrssdssssrsshd
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit
counterfeit

Please log in to submit a solution to this problem

Log in