Naive Algorithm (First Occurrence)
Given two strings, P and T: P is the pattern, and T is the text in which we will search for P using the naive search algorithm. This involves comparing P character-by-character with each substring of T that has the same length as P.
The substrings of T are checked sequentially from left to right, and within each substring, the characters are compared from left to right. For each character comparison, the character from P that is being compared must be printed. After completing the search, output the starting position in T where the pattern P is found, or output 0 if the pattern P is not present in the text T.
Input Data
The first line of the input contains the pattern P (1 ≤ size(P) ≤ 100), and the second line contains the text T (1 ≤ size(T) ≤ 100).
Output Data
On the first line of the output, print the characters of the pattern P that are being compared. On the second line, print the position of the first occurrence of the pattern P in the text T, or 0 if the pattern is not found. Format the input and output data according to the example.