AT_abc454_e [ABC454E] LRUD Moving

Description

You are given positive integers $ N,A,B $ . It is guaranteed that both $ A $ and $ B $ are between $ 1 $ and $ N $ , inclusive. There is an $ N\times N $ grid. The cell at the $ i $ -th row from the top and $ j $ -th column from the left is denoted as cell $ (i,j) $ . Initially, a piece is placed at cell $ (1,1) $ . By repeating $ N^2-2 $ moves, each of which moves the piece to an adjacent cell (up, down, left, or right), you want to move the piece to cell $ (N,N) $ while visiting every cell except cell $ (A,B) $ . You must not visit the same cell more than once (you must not visit cells $ (1,1) $ and $ (N,N) $ in the middle, either). Determine whether such a sequence of moves is possible, and if so, output one such sequence. You are given $ T $ test cases; solve each of them.

Input Format

The input is given from Standard Input in the following format: > $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $ Each test case is given in the following format: > $ N $ $ A $ $ B $

Output Format

Output the answers for the test cases in order, separated by newlines. For each test case, if it is impossible to perform a sequence of moves satisfying the conditions, output `No`. If it is possible, output in the following format: > Yes $ S_1S_2\ldots S_{N^2-2} $ Here, $ S_k $ is defined as follows, where the coordinates of the piece before the $ k $ -th move is cell $ (i,j) $ . - $ S_k= $ `L` if the piece moves from cell $ (i,j) $ to cell $ (i,j-1) $ - $ S_k= $ `R` if the piece moves from cell $ (i,j) $ to cell $ (i,j+1) $ - $ S_k= $ `U` if the piece moves from cell $ (i,j) $ to cell $ (i-1,j) $ - $ S_k= $ `D` if the piece moves from cell $ (i,j) $ to cell $ (i+1,j) $ If multiple sequences of moves satisfy the conditions, any of them will be accepted.

Explanation/Hint

### Sample Explanation 1 Consider the first test case. Starting with the piece at cell $ (1,1) $ , move it twice as follows: - Move the piece downward. The piece moves to cell $ (2,1) $ . - Move the piece rightward. The piece moves to cell $ (2,2) $ . This sequence of moves satisfies the conditions. ### Constraints - $ 1\le T \le 5000 $ - $ 2\le N\le 10^3 $ - $ 1\le A,B\le N $ - $ (A,B)\neq (1,1),(N,N) $ - The sum of $ N^2 $ over all test cases is at most $ 10^6 $ . - All input values are integers.