ADITYA13 - FizzBuzz Happy 2013

no tags 

Having cleared the ACM ICPC online round you receive a job offer of teaching JAVA programming to High School Students of Byteland. You gladly take the job offer and after a few days of teaching you give the students a program to write. You ask them to write a FIZZBUZZ program. They are either too smart or too lazy. They argue that it is too difficult and challenge you to do better than that without using any English letters. You consult senior programmer Mitch who suggests you a way out of the problem. "Do it in BF," he says. Tjandra suggests you do it in Whitespace.

Input

Two space separated one digit integers A and B. Then a newline. Then a string C of maximum length 5 followed by a newline. Then another string D of max length 5 followed by a newline. It is guaranteed that gcd(A,B) < A and gcd(A,B) < B. Also the strings comprise only alphanumeric characters.

Output

For all numbers in the set [1, 99] print C if the number is divisible by A, print D if divisible by B, print C concat D if divisible by both and the number (with preceding zeroes if required) if it divisible by neither A nor B.

Example

Input:
2 3
Happy
2013

Output:
01
Happy
2013
Happy
05
Happy2013
07
..........and you get the idea

Wishing all of you a HAPPY NEW YEAR 2013 :)

Edit: 05-01-2013 I am giving you all a link to mostafa_36a2's solution. You would be pleased... Download the encrypted text solution


hide comments
(Tjandra Satria Gunawan)(曾毅昆): 2013-01-05 09:14:01

Thanks Aditya Pande, But I still can't solve this problem with WSPC programming language :-P So I suggests to other users to solve it with WSPC, hahaha..
Happy New Year 2013 too :-D
Nice problem.. took exactly 2 hours for me to solve it ;-)
Btw, I think Pyramid cluster is better for this problem, so the user that solve this problem can easily know which code is faster...


Added by:Aditya Pande
Date:2013-01-01
Time limit:1s-5.116s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:BF WHITESPACE
Resource:Own