Under construction

Still being built. Things may change

Don't Stay

Time limit2sMemory limit512 MB

Summary
Given a lamplighter program s and the set of lamps that must be on, find a prefix program t that is undone after s so the final lamp state matches the target.
Level

Medium7 of 10

Topics
Simulation, String, Implementation
Solved
No attempts yet

Problem

There are infinitely many lamps on a line, numbered with integers. Each lamp can be either turned on or turned off. A lamplighter starts at lamp number 00. He can walk one lamp left or right (that is, decrease or increase his coordinate by 11) and toggle the lamp at his position. We denote these actions with letters "L", "R" and "X", respectively.

A string of letters "L", "R" and "X" is called a program for the lamplighter. For example, if he is currently at position 00 and receives the string "RRXL", he goes right twice, toggles the lamp at position 22, and then goes left and ends up at position 11.

Initially, all lamps are turned off. In the end, you want to achieve a state where the lamps with coordinates a1a_1, …\ldots, ana_n are turned on, and all other lamps are turned off. The lamplighter has a program ss which he is going to execute, and he does not want to change his plans much. However, he agreed to help you a bit. If you give him a program tt, he will start by executing all instructions from tt. Then he will execute his own program ss, as he planned before. After that, he will try to cancel your help by performing all instructions from tt in reverse order, changing "L" to "R" and vice versa.

Given the coordinates aia_i and the lamplighter's program ss, find a program tt such that in the end, lamps a1a_1, …\ldots, ana_n are on and all other lamps are off, or determine that it is not possible.

Input

The first line contains a string ss (1≤∣s∣≤2⋅1051 \leq |s| \leq 2 \cdot 10^5) consisting of the characters "L", "R" and "X": the initial program of the lamplighter.

The second line contains an integer nn (0≤n≤2⋅1050 \leq n \leq 2 \cdot 10^5), the number of lamps that should be turned on in the end. The third line contains nn space-separated integers: the coordinates of the lamps. All given coordinates are distinct and their absolute values do not exceed 2⋅1052 \cdot 10^5.

Output

Output the string tt that you can give to the lamplighter to achieve the goal. If there are several possible answers, output any one of them. The answer may be empty. The length of the answer must not exceed 2⋅1062 \cdot 10^6 characters.

If achieving the goal is not possible, print a single word "NO" (without quotes).

Note

In the example, the lamplighter has the string "RXR", and the desired lamp positions are −2-2, 00, and 22. You can give the lamplighter the string "XLLXR". His combined program then becomes "XLLXR-RXR-LXRRX" (dashes added for clarity).

The lamplighter lights lamp number 00, then goes to −2-2 and lights it, goes back to 00 and turns it off, turns it on again, and finally goes to 22 and turns it on. In the end, the state of all lamps is the one you wanted.

Examples1

  1. Example 1

    Input
    RXR
    3
    -2 0 2
    
    Expected output
    XLLXR