The organiors of Terratechnica have bought a lots of stools for sitting arrangement.
Because of some reason, the organisors forgor to order some larger benches to accomodate more people.
But the, stools are not the normal stools,
they have some power of attraction. They assemble themselves together according to the given condition.
Thus the stools with affinity for each other are kept in a room and allowed to spontaneously
assemble themselves into larger structures.
But there is one problem: sometimes stools
assemble themselves into a structure of unbounded size(infinite size), which exceeds the size of room.
You must write a program to decide whether a given collection of stools can be assembled into a
structure of unbounded size.
You should make two simplifying assumptions:
1) the problem is restricted
to two dimensions, and
2) each stool in the collection is represented as a square. The four edges of
the square represent the surfaces on which the stools can connect to other compatible stools.
In each test case, you will be given a set of stool descriptions.
Each type of stool is described
by four two-character connector labels that indicate how its edges can connect to the edges of other
stools.
The connector labels on the stool are of two types::
• An uppercase letter followed by + or −. Two edges of the stool are compatible if their labels have
different signs but same letter . For example, Z+ is compatible with Z− but is not compatible
with C+ or N−.
• Two zeros 00. An edge with 00 is not compatible with any edge .
Assume there is an unlimited supply of stools of each type, which may be rotated and reflected. As
the stools assemble themselves into larger structures, the edges of two stools may be adjacent
to each other only if they are compatible. It is permitted for an edge, regardless of its connector label, to
be connected to nothing (no adjacent stool on that edge).
Figure A.1 shows an example of three stool types and a structure of bounded size that can be assembled
from them (other bounded structures are also possible with this set of stools).
Input
The input consists of a single test cases. A test case consists of two lines.
The first contains an integer n
(1 ≤ n ≤ 40 000) indicating the number of molecule types. The second line contains n eight-character
strings, each describing a single type of molecule, separated by single spaces. Each string consists of
four two-character connector labels representing the four edges of the molecule in clockwise order.
Output
Display the word "unbounded"(without quotes) if the set of molecule types can generate a structure of unbounded size.
Otherwise, display the word "bounded".