You are on page 1of 2

Problem 1 file:///home/bitwise/Desktop/probs_html/prob1.

html

TO KEEP THE LUCKY COIN SAFE (100 points)

Scrooge earned his first dime in 1877 in his hometown of Glasgow, when he started
working as a shoeshine boy on his tenth birthday. Scrooge felt cheated as a dime was
of no value in Scotland, and kept it with him as a reminder not to get cheated again.
Others feel that Scrooge's Number One Dime is a lucky charm. Magica wants to steal
the coin and melt it in the fires of Mount Vesuvius (her residence) to turn it into a
powerful amulet capable of granting the Midas touch.

She has hired the Beagle boys to do the dirty work. Scrooge comes to know of her
nefarious plans and has ordered his men to build a safe to protect his coin. Gryo
comes up with Quackanium bricks which he claims to be unbreakable. The bricks are
rectangles of dimensions 2*1 and the safe door is a m*2n rectangle. Magica has
provided the Beagle Boys with laser cutters that can cut all materials except
Quackanium . Any attempt to cut a Quackanium brick raises a beagle alarm. The
Beagle boys have a chance of stealing the coin only if there is a horizontal or vertical
line through the safe door which is not crossed by a Quackanium brick. Help Gyro
design the safe so that the Beagle boys have no chance of stealing the coin. Gyro
knows that there exists atleast one fault free safe for values of m>=5 and n>=3 and
m,n are not simultaneously equal to 6,3 respectively. Assume that this condition on
m,n will be satisfied for all the test cases.

Input Format:

The first line of the input contains the number of test cases.

Each subsequent line contains the space separated values of m & n for each test case.
Assume m, n cannot be greater than 1000.

Output Format:

For the sake of representing the safe let us use the characters 'u' and 'd' for denoting
the top and bottom portion of a vertical brick and 'l' and 'r' for denoting the left and
right portion of a horizontal brick respectively. (A brick placed in the vertical position
is represented by u in the upper row and d just below, while a brick placed in
horizontal position is represented by l and r.)

Print the safe configuration on the standard output followed by 0 for each test case.

Sample input:

53

64

Sample output:

ulrlru

duulrd

uddulr

dlrduu

lrlrdd

1 of 2 Sunday 10 February 2008 11:46 AM


Problem 1 file:///home/bitwise/Desktop/probs_html/prob1.html

lrlrlruu

uulrlrdd

ddulrulr

lrduudlr

ulrddlru

dlrlrlrd

2 of 2 Sunday 10 February 2008 11:46 AM

You might also like