Unknown Language Round 3 |
---|
Finished |
There are a lot of rumors in the media these days. One day Aida decided to find out how rumors are made.
She asked n of her friends to help her. They all formed a circle and Aida told the person to her right a piece of news which was just a simple string. Then each person told the string to the person on his/her right. But they didn't tell the string exactly as they'd heard it. Each person made at most one of these two types of changes:
Finally when the rumor passed exactly n moves (a complete cycle), Aida heard something quite different from what she expected from the person on her left. She thinks someone has cheated and made some changes other than those explained above. Now she wants you to write a Pike piece of code which gets the initial and final strings and tells Aida whether it's possible to get to the final string from the initial one, by the rules described above.
The first line contains a single integer n (2 ≤ n ≤ 8 × 106), the number of Aida's friends. The following two lines contain a non-empty string each — initial and final strings. The lengths of strings are at most 107 and they only contain English alphabet letters.
Write a single YES or NO. Write YES only if it's possible to get to the final string from the initial string.
100
Codeforces
MMIODPC
Yes
5
MMIOD
CF
No
The input is case-sensitive, while the output is not.
Name |
---|