The Good Tablecloth
Whenever guests come over, Mom always brings out the good dishes and the good tablecloth. But tomorrow, she has an unexpected visit, and the tablecloth is in the laundry! So, she asks Toto for help to color an old tablecloth, hoping to save the day.
She is very strict about what makes a good tablecloth:
- It has only colors: red and green.
- It has horizontal and vertical lines dividing it into rectangular sections (parts).
- To make the lines visible to the eye, the parts that share an edge must be colored differently.
She hands the tablecloth to Toto and specifies the lines she wants to see. Totos needs to color it appropriately.
Input Data (STDIN
)
The first line of input provides positive integer numbers:
- , the length, and
- , the width of the tablecloth, separated by a space (
' '
).
The next line starts with a positive integer , the number of horizontal lines, followed by a new line containing positive integers , separated by spaces (' '
), where is the distance of the line from the top edge of the tablecloth.
This is followed by a new line that starts with a positive integer , the number of vertical lines, followed by a new line containing positive integers , separated by spaces (' '
), where is the distance of the line from the leftmost edge of the tablecloth.
It holds that .
Output Data (STDOUT
)
The program will output lines, each containing characters, which are either G
or R
, such that the resulting output forms the tablecloth after Toto's intervention.
Note: If there are more than possible answers, print any you prefer.
Examples
1st
Input (STDIN)
4 5
1 2
2 1 4
Output (STDOUT)
GRRRG
GRRRG
RGGGR
RGGGR
2nd
Input (STDIN)
4 5
3 1 2 3
4 1 2 3 4
Output (STDOUT)
GRGRG
RGRGR
GRGRG
RGRGR
Subtasks
- of the points:
- of the points:
The same line-column may appear multiple times: if it appears an odd number of times, it should appear on the tablecloth; otherwise, it should not.
Comments