Hide

Problem N
Mætingarlisti

Languages en is
/problems/maetingarlisti/file/statement/en/img-0001.jpg
Classroom (image from flickr.com)

An attendance list is passed around a classroom with each student writing their name below the name of the last student who had the list (the first person writes their name at the top). The classroom consists of $r$ rows where each row has $c$ chairs. The class is popular enough that every chair will be filled. Your assignment is to write a program which finds out whether the attendance list was passed from left to right or from right to left for each row in the classroom.

Input

The first line of the input contains three integers $4 \leq n \leq 10^5$, $r$, and $c$, where $n = r \cdot c$. Then there are $r$ lines, each line with $c$ names, where each line denotes a single row of students. Then there are $n$ lines, each line with a single name, denoting the attendance list.

Each name consists of $2$ to $20$ English lowercase letters and $c \geq 2$.

Output

Print $r$ lines, where line $i$ is either left if the attendance list was passed from left to right in the $i$-th row, but print right otherwise.

Scoring

Group

Points

Constraints

1

10

$4 \leq n \leq 50$

2

90

No further constraints

Sample Input 1 Sample Output 1
6 2 3
benni arnar unnar
bjarki atli hannes
benni
arnar
unnar
hannes
atli
bjarki
left
right
Sample Input 2 Sample Output 2
4 2 2
patryk anna
karl unnsteinn
patryk
anna
karl
unnsteinn
left
left

Please log in to submit a solution to this problem

Log in