TORONTO KIDS COMPUTER CLUB | Markham Saturday 14:00 Java Homework 20.06.06.
post-template-default,single,single-post,postid-17646,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Markham Saturday 14:00 Java Homework 20.06.06.

12 Jun Markham Saturday 14:00 Java Homework 20.06.06.

When moving, ants form rows so that each ant except the first is behind another ant. It is not widely known what happens when two rows of ants moving in opposite directions run into each other in a passage too narrow for both rows to pass through. One theory says that, in that situation, ants will jump over each other.

From the moment the rows meet, each second every ant jumps over (or gets jumped over, as they agree upon) the ant in front of himself so that the two ants swap places, but only if the other ant is moving in the opposite direction. Find the order of the ants after T seconds.

Input Specification
The first line contains two integers N1 and N2, the numbers of ants in the first and second rows, respectively.

The next two rows contain the orders of ants in the first and second row (first to last). Each ant is uniquely determined by an uppercase letter of the English alphabet (this letter is unique between both rows).

The last line of input contains the integer T (0≤T≤50).

Output Specification
Output the order of the ants after TT seconds on a single line. Our viewpoint is such that the first row of ants comes from our left side and the other one from our right side.

Sample Input 1
3 3

Sample Output 1

Sample Input 2
3 3

Sample Output 2

Sample Input 3
3 4

Sample Output 3
No Comments

Sorry, the comment form is closed at this time.