Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Country of Alphabet

By rakibahmed · Limits 1s, 512 MB

In an imaginary galaxy, there is a planet where two Countries are very unique for their Houses. In those countries, people make their houses in Uppercase Alphabetic shape. Levi and Eren are the presidents of those countries. There are total NN number of houses in Levi’s Country and MM number of houses in Eren’s Country. Levi is a very strict president so he declared that in his country all the houses should be aligned sequentially, on the other hand, Eren doesn’t care about the sequence because he is a wise and flexible president.

ADPRWADPRW is sequentially aligned whereas PADWRPADWR is not sequentially aligned.

For Levi’s strict and mad decision, he’s the headline of the World News. On the other hand, for Eren’s flexibility, he earned the prestigious Nobel Peace. Since the houses should be aligned sequentially in Levi’s country, some houses might shift from one position to another with a very long distance. After sequentially aligning the houses of Levi’s country, if we compare Levi and Eren’s country’s houses then there might be some houses that look the same in terms of their shape. If there are any of the houses LiL_{i} of Levi’s country look the same as any of the houses EjE_{j} of Eren’s country then you have to calculate the ratio of their Position.

For example, if the houses of Levi’s country become ADPRWADPRW after sequentially aligned and if the houses of Eren’s country are aligned in this way — KWLAKWLA. Then, WW and AA are the common houses among them. In Levi’s country, WW is located at 5th5^{th} position, and in Eren’s country, WW is located at 2nd2^{nd} position. In Levi’s country, AA is located at 1st1^{st} position, and in Eren’s country, AA is located at 4th4^{th} position. For WW shaped houses, the ratio is 5:25:2, and for AA shaped houses, the ratio of their position is 1:41:4.

Now, If there are any of the houses of Levi’s country look the same as the houses of Eren’s country then, your task is to calculate the ratio of the house’s position. If not found then, print “unmatched“ without quotes.

If there are same-shaped houses in the same country or another country appear more than once, then consider only for the first house.

Input

The first line of the input contains NN (1N1001 \leq N \leq 100) — The number of houses in Levi’s country.

The second line of the input contains a string — The sequence of the NN number of Houses of Levi’s Country.

The third line of the input contains MM (1M1001 \leq M \leq 100) — The number of houses in Eren’s country.

The fourth line of the input contains a string — The initial sequence of the MM number of Houses of Eren’s Country.

Output

For each input, If there are any of the houses of Levi’s country look the same as the houses of Eren’s country then, you have to print all the ratios of the house’s position. If not found then, print “unmatched“ without quotes.

Samples

InputOutput
5
ADPRW
4
KWLA
1:4
5:2
InputOutput
5
HDKAP
5
XBZYI
unmatched
InputOutput
9
BDAPOATBD
6
VDFABA
1:4
3:5
5:2

    Discussion

    Statistics


    33% Solution Ratio

    MursaleenEarliest, 1w ago

    MursaleenFastest, 0.0s

    MursaleenLightest, 131 kB

    MursaleenShortest, 883B

    Submit

    Login to submit