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 $N$ number of houses in Levi’s Country and $M$ 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.

$ADPRW$ is sequentially aligned whereas $PADWR$ 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 $L_{i}$ of Levi’s country look the same as any of the houses $E_{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 $ADPRW$ after sequentially aligned and if the houses of Eren’s country are aligned in this way — $KWLA$. Then, $W$ and $A$ are the common houses among them. In Levi’s country, $W$ is located at $5^{th}$ position, and in Eren’s country, $W$ is located at $2^{nd}$ position. In Levi’s country, $A$ is located at $1^{st}$ position, and in Eren’s country, $A$ is located at $4^{th}$ position. For $W$ shaped houses, the ratio is $5:2$, and for $A$ shaped houses, the ratio of their position is $1: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.**

The first line of the input contains $N$ ($1 \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 $N$ number of Houses of Levi’s Country.

The third line of the input contains $M$ ($1 \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 $M$ number of Houses of Eren’s Country.

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.

Input | Output |
---|---|

5 ADPRW 4 KWLA | 1:4 5:2 |

Input | Output |
---|---|

5 HDKAP 5 XBZYI | unmatched |

Input | Output |
---|---|

9 BDAPOATBD 6 VDFABA | 1:4 3:5 5:2 |

Login to submit.

40%
Solution Ratio

MursaleenEarliest,

n3wb13_223Fastest, 0.0s

MursaleenLightest, 131 kB

MursaleenShortest, 883B

Toph uses cookies. By continuing you agree to our Cookie Policy.