Naive Algorithm – 2 (First Occurrence)#8227

Naive Algorithm – 2 (First Occurrence)

1 secondo
64 megabyte
Molto facile

Given two strings, and : is the pattern, and is the text where we will search for using a modified version of the naive search algorithm. In this algorithm, substrings of are traversed from left to right, while the characters of the strings are compared from right to left. During each character comparison, the character from being compared must be printed. After completing the search, print the starting position of in , or print if does not appear in .

Input

The first line of the input contains the pattern (1 \leq \text{size}(P) \leq 100), and the second line contains the text (1 \leq \text{size}(T) \leq 100).

Output

On the first line of the output, print the characters of the pattern that are compared. On the second line, print the position of the first occurrence of the pattern in the text , or if it does not occur. Format the input and output data according to the example.

Esempi

Esempio 1

Loading
Loading