#K70447. Symmetrical Numbers Specialization
Symmetrical Numbers Specialization
Symmetrical Numbers Specialization
You are given two sets of numbers represented as strings: a set of favorite symmetrical numbers and a set of chest symmetrical numbers found in a treasure chest.
Your task is to determine for each chest number if it is "Special" or "Ordinary" by using the following rules:
- If the chest number has a length of at least 5, it is automatically classified as Special.
- If its length is less than 5, check if any of the favorite symmetrical numbers appears as a substring in the chest number. If yes, it is Special; otherwise, it is Ordinary.
Note: All numbers are provided in string format.
The problem might include formulas in LaTeX format. For example, the length condition is given by: \( len(chest) \ge 5 \).
inputFormat
The input is given from standard input (stdin) and has the following format:
L M favorite_1 favorite_2 ... (L favorites in total) chest_1 chest_2 ... (M chest numbers in total)
Here, L is the number of favorite symmetrical numbers and M is the number of chest symmetrical numbers.
outputFormat
Print M lines to standard output (stdout). Each line should contain the word Special or Ordinary corresponding to each chest number in the order they are given.
## sample2 4
121
1221
12321
454
75557
1234554321
Special
Ordinary
Special
Special
</p>