#ABC474G. LRUD 移动 2 / LRUD Moving 2

LRUD 移动 2 / LRUD Moving 2

Problem Statement

You are given positive integers NN and KK.

There is an N×NN\times N grid. The cell at the rr-th row from the top and the cc-th column from the left is denoted as cell (r,c)(r,c).

Initially, a piece is placed on cell (1,1)(1,1).

You will perform the following operation exactly N21N^2-1 times so that the piece ends up in cell (N,N)(N,N):

  • Move the piece one cell to a cell vertically or horizontally adjacent to the cell it is currently on.

Here, over the course of the movement, each of the N2N^2 cells must be visited exactly once. Cell (1,1)(1,1), where the piece is initially placed, is considered visited.

Determine whether there exists a sequence of operations where the piece moves one cell to the right exactly KK times, and if it exists, find one such sequence.

You are given TT test cases; solve each of them.

Constraints

  • 1T5×1031\le T\le 5\times 10^3
  • 2N1032\le N\le 10^3
  • 0KN210\le K\le N^2-1
  • The sum of N2N^2 over all test cases is at most 10610^6.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • TT
  • case1\text{case}_1
  • case2\text{case}_2
  • \vdots
  • caseT\text{case}_T

Each test case is given in the following format:

  • NN KK

Output

Output the answers for the test cases in order, separated by newlines.

For each test case, if there is no sequence of operations satisfying the condition, output No.

If there exists a sequence of operations satisfying the condition, output it in the following format:

  • Yes\text{Yes}
  • S1S2SN21S_1S_2\dots S_{N^2-1}

Here, SkS_k represents the kk-th move, and is one of the following:

  • Sk=S_k= L if the piece moves one cell to the left
  • Sk=S_k= R if the piece moves one cell to the right
  • Sk=S_k= U if the piece moves one cell up
  • Sk=S_k= D if the piece moves one cell down

If there are multiple sequences of operations satisfying the condition, any of them will be accepted.

3
3 4
2 1
5 10
Yes
RRDLLDRR
No
Yes
RRRRDDDLLLURRULLLDDDRRRR

Consider the first test case.

By moving from cell (1,1)(1,1) in order to cells (1,2),(1,3),(2,3),(2,2),(2,1),(3,1),(3,2),(3,3)(1,2),(1,3),(2,3),(2,2),(2,1),(3,1),(3,2),(3,3), you can move one cell to the right four times and reach cell (3,3)(3,3).