Under construction

Still being built. Things may change

Daily Trips

Interview

Time limit0.1sMemory limit1024 MB

Summary
Simulate Bella's umbrella rule over N days and output, for each of the 2N bus trips, whether she carries an umbrella.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Statement

Bella is a simple girl with a simple life: wake up, go to work, work, go home, rest, sleep, and repeat. She commutes by bus, and it rains often in her city, so sometimes she needs an umbrella. The local weather forecast is unreliable, so Bella cannot be sure whether it will rain until right before she starts a trip. To avoid getting caught unprepared, she follows a system.

She has one or more umbrellas, kept at home or at work. Before each trip (from home to work, or from work to home), she looks outside and decides whether to bring an umbrella:

  • If it is raining, she brings an umbrella.
  • Otherwise, if there are currently no umbrellas at her destination (work or home), she brings one anyway, just in case.
  • Otherwise, she does not bring an umbrella.

The second rule prevents her from needing an umbrella at a place where she has none. This guarantees she never gets caught in the rain and gets sick.

Simulate Bella's method over a period. The simulation starts with Bella at home. Each day she makes two bus trips, to work and back. You are given the starting numbers of umbrellas at home and at work, and the weather for NN consecutive days. For each of the 2N2N bus trips, determine whether Bella brought an umbrella.

Input

The first line contains three integers NN (1≤N≤1041 \le N \le 10^4), HH (1≤H≤1001 \le H \le 100), and WW (0≤W≤1000 \le W \le 100): the number of days, the starting number of umbrellas at home, and the starting number of umbrellas at work. Each of the next NN lines contains two characters separated by a space. The first character is for the trip from home to work on that day, and the second is for the trip from work to home. Each character is Y if it rained on that trip and N otherwise.

Output

Output NN lines. The ii-th line contains two characters for day ii: the first for the trip from home to work, and the second for the trip from work to home. Each is Y if Bella brought an umbrella on that trip and N otherwise.

Examples1

  1. Example 1

    Input
    5 2 1
    Y N
    N N
    Y N
    N Y
    Y Y
    
    Expected output
    Y N
    N N
    Y Y
    N Y
    Y Y