An automated chemistry lab is experimenting with a process called self-assembly. Molecules that have a natural affinity for one another are mixed in a solution and allowed to spontaneously join into larger structures. There is one danger: sometimes the molecules assemble into a structure of unbounded size, which jams the machinery.
Write a program that decides whether a given collection of molecules can assemble into a structure of unbounded size. Make two simplifying assumptions: (1) everything happens in two dimensions, and (2) each molecule is a square. The four edges of the square are the surfaces on which the molecule can connect to other compatible molecules.
Each type of molecule is described by four two-character connector labels, one per edge, that say how that edge can connect to the edges of other molecules. There are two kinds of connector label:
A to Z) followed by + or -. Two edges are compatible when their labels use the same letter but opposite signs. For example, A+ is compatible with A-, but not with A+ or B-.00. An edge with this label is not compatible with any edge, not even another edge labeled 00.You have an unlimited supply of each molecule type, and molecules may be rotated and reflected freely. When molecules assemble into larger structures, two edges may be placed next to each other only if they are compatible. Any edge, whatever its label, is allowed to connect to nothing, that is, to have no neighboring molecule on that side.
As an illustration, there are sets of three molecule types from which only structures of bounded size can be assembled, and more than one bounded structure may be possible from the same set.
The input is a single test case spread over two lines. The first line contains an integer n (1≤n≤40000), the number of molecule types. The second line contains n eight-character strings, separated by single spaces, each describing one molecule type. Each string is four two-character connector labels giving the molecule's four edges in clockwise order.
Print the single word unbounded if the set of molecule types can generate a structure of unbounded size. Otherwise print the single word bounded.