Under construction

Still being built. Things may change

Obedient Tom

Interview

Time limit1sMemory limit1024 MB

Summary
Simulate placing N colored toys into three capacity-K boxes, trying each toy's preferred box, then the next box in the A-B-C cycle when it is full.
Level

Easy2 of 10

Topics
Simulation, Array
Solved
No attempts yet

Problem

Tom has NN toys scattered around the room. His mother gave him three boxes for storing them. Each box holds KK toys, and the three boxes together have enough room for all of the toys.

Tom first decided on a simple rule. Blue toys go into box A, green toys go into box B, and red toys go into box C. Then he wondered what would happen if not every toy fit into the box for its color. So he added another rule: if a toy cannot go into box A, he tries box B instead. If it cannot go into B, he tries C instead of B, and if it cannot go into C, he tries A instead of C.

Input

The first line contains two integers NN and KK (0≤N≤1000 \le N \le 100, K≤40K \le 40, N≤3⋅KN \le 3 \cdot K), the number of toys and the number of toys that fit in one box.

The second line contains a string of length NN made of the letters 's', 'r', and 'p'. The letters give the colors of the toys in the order they are placed into the boxes: 's' is blue, 'r' is green, and 'p' is red.

Output

Print three lines. The first line is the colors of the toys in box A, the second line is the colors of box B, and the third line is the colors of box C. In each line, the colors appear in the order the toys were placed into that box.

Examples1

  1. Example 1

    Input
    6 2
    rrprps
    
    Expected output
    ps
    rr
    pr