printЗанятие 5 (подготовка к олимпиаде)

printD. Secret Research

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of its completion: 'positive result', 'negative result', 'experiment failed' or 'experiment not completed'.
The encrypted result constitutes a string of digits S, which may take one of the following forms:
  • positive result S = 1 or S = 23 or S = 2S3
  • negative result S = 51S
  • experiment failed S = 5S
  • experiment not completed S = 2S1 or S = 24S
(A sample result 51S means that if we add digits 51 from the left hand side to a digit sequence then we shall get the digit sequence corresponding to a failed experiment)
You are to write a program which decrypts given sequences of digits.
Input
A integer `n` stating the number of encrypted results and then consecutive `n` lines, each containing a sequence of digits given as ASCII strings.
Output
For each analysed sequence of digits the following lines should be sent to output (in separate lines):
+ for a positive result
- for a negative result
* for a failed experiment
? for a not completed experiment

Sample Input

4
23
5123
222331
523

Sample Output

+
-
?
*
loading