DSLR

No attempts yetTime limit6sMemory limit256 MB

Problem

There is a simple calculator that uses four commands: DD, SS, LL, and RR. The calculator has a single register that stores a decimal number nn with 0n<100000 \le n < 10000. Each command transforms the value nn currently in the register. Let the four digits of nn be d1,d2,d3,d4d_1, d_2, d_3, d_4, so that n=((d1×10+d2)×10+d3)×10+d4n = ((d_1 \times 10 + d_2) \times 10 + d_3) \times 10 + d_4.

  • D: doubles nn. If the result is greater than 99999999, it is reduced modulo 1000010000; that is, the register receives 2nmod100002n \bmod 10000.
  • S: stores n1n - 1. If nn is 00, it stores 99999999 instead.
  • L: rotates the four digits of nn one place to the left. Afterwards the digits, from the left, are d2,d3,d4,d1d_2, d_3, d_4, d_1.
  • R: rotates the four digits of nn one place to the right. Afterwards the digits, from the left, are d4,d1,d2,d3d_4, d_1, d_2, d_3.

LL and RR always rotate over four decimal digits. For example, if n=1234n = 1234, then LL gives 23412341 and RR gives 41234123.

Given two distinct integers AA and BB (ABA \ne B), write a program that finds the shortest command string that turns AA into BB. For example, if A=1234A = 1234 and B=3412B = 3412, two commands suffice in either of these ways:

  • apply LL twice: 1234234134121234 \to 2341 \to 3412
  • apply RR twice: 1234412334121234 \to 4123 \to 3412

Here the two shortest command strings are LL and RR, and you must output LL, which comes first in alphabetical order.

Be careful when a digit is 00. For example, applying LL to 10001000 gives 00010001, so the result is 11; applying RR gives 01000100, so the result is 100100.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains two integers AA and BB separated by a space, where AA is the register's initial value and BB is the target value. Both satisfy 0A,B<100000 \le A, B < 10000 and ABA \ne B.

Output

For each test case, print on its own line the shortest command string that turns AA into BB. If several command strings share the minimum length, print the lexicographically smallest one, comparing command letters in alphabetical order D<L<R<SD < L < R < S.