PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000033. Tự lắp ghép phân tử (Self-Assembly)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tự lắp ghép phân tử (Self-Assembly)

Self-Assembly

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

Each square molecule has four connectors labeled with uppercase letter and sign or 00. Matching opposite signs can bond; molecules can rotate or flip. Determine whether arbitrarily large assemblies are possible.

Input

Integer nn, followed by nn strings of length 8, each encoding four two-character connector labels.

Output

Print unbounded for unlimited assembly, otherwise bounded.

Subtasks

  • Subtask 1 (40 points): n≤20n\le20; 1≤n≤400001\le n\le40000; each connector is 00 or an uppercase letter followed by + or -; molecule types may repeat.
  • Subtask 2 (60 points): 1≤n≤400001\le n\le40000; each connector is 00 or an uppercase letter followed by + or -; molecule types may repeat.

Examples

Input

1
K+K-Q+Q-

Output

unbounded

Explanation

The molecule has complementary K+/K- and Q+/Q- connectors. These induce a cycle in the connector-state graph, allowing unbounded repetition.