Under construction

Still being built. Things may change

Folding Code

Time limit2sMemory limit256 MB

Summary
The program reflects each folded corner across its fold line to find the ticked box and lists the chosen answers per question.
Level

Easy3 of 10

Topics
Geometry, Implementation
Solved
No attempts yet

Problem

The organisers handed out paper evaluation forms at the end of the contest. That was a surprise for a programming contest team that did all of its work digitally. Nobody on the team carried a pen or a pencil, and borrowing one was not an option. They still wanted to submit their evaluations. The form was multiple choice, so answering a question only meant marking the preferred option, and the team worked out a way of filling in the form by folding it.

To answer a question they folded one of the corners of the page over so that it landed on the box of the option they wanted, and creased the paper along the straight fold line. The choice of corner was free. After answering a question they flattened the paper again, and they repeated the process for every answer they wanted to give. The result is a sheet of paper with one fold line for each answer.

Reading such a form back is easy: make each fold again and see where it points. The organisers were digital enthusiasts too. They scanned every evaluation form, destroyed it, and analysed the scans. The scans still showed a shadow along each fold line, so an operator could record the points at which a fold line met the edge of the paper.

Given the list of fold line endpoints and the positions and sizes of the questions, the options and the tick boxes, decode the evaluation form.

A fold line always joins two points that lie on adjacent edges of the page. The corner shared by those two edges is the corner that was folded, and the mirror image of that corner across the fold line is the point the fold points at. That point always lies inside a tick box.

Here is an example evaluation form. In the right image the top right corner has been folded over to give the answer "Perfect" to the first question.

Input

The first line contains four integers WW, HH, QQ and FF. WW and HH are the width and the height of the form in mm (100≤W,H≤1000100 \le W, H \le 1000), QQ is the number of questions on the form (0<Q≤100 < Q \le 10), and FF is the number of folds to decode (0<F≤1000 < F \le 100).

Then QQ question descriptions follow. The first line of each question description holds five integers AA, xx, yy, ww, hh followed by the text of the question. AA is the number of answers to the question (0<A≤100 < A \le 10). The values xx and yy are the coordinates of the top left corner of an enclosing rectangle for the question text, and ww and hh are its width and height (0<x+w<W0 < x + w < W, 0<y+h<H0 < y + h < H).

The next AA lines hold one answer description each. Each line holds eight integers x1x_1, y1y_1, w1w_1, h1h_1, x2x_2, y2y_2, w2w_2, h2h_2 followed by the text of the answer. The first four values define an enclosing rectangle for the answer text and the last four define the tick box. (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) are the top left corners of the two rectangles, and w1w_1, h1h_1, w2w_2, h2h_2 are their widths and heights. All rectangles have positive area and fit within the page. No two rectangles overlap, but they may touch. Every question text and answer text is non-empty and at most 100 characters long.

After the question descriptions come FF lines, each describing one fold. Each line holds four integers x1x_1, y1y_1, x2x_2, y2y_2, the coordinates of the two points at which the fold meets an edge of the paper.

The coordinate system is in millimetres, (0,0)(0, 0) is the top left corner of the page and (W,H)(W, H) is the bottom right corner. A point where a fold meets an edge has one coordinate that is exactly 00 (top or left), WW (right) or HH (bottom). A fold line runs between adjacent edges and never passes through a corner. No tick box is ticked by more than one fold, and FF is at most the total number of tick boxes. Every fold is valid: the point it points at lies inside a tick box and is at least 0.10.1 mm away from the border of that box.

All items on a line are separated by a single space. The input contains a single form.

Output

Print one line per question, in the order the questions are given. Each line holds the question text, a colon, a space, and then the texts of the ticked answers of that question joined by a semicolon and a space (; ). List the answers in the order they are given in the input. For a question with no ticked answer print only the question text and the colon. Some questions have more than one answer.

Examples2

  1. Example 1

    Input
    210 150 3 3
    4 9 19 121 10 Rate your contest experience
    9 29 33 10 43 29 10 10 Terrible
    57 29 32 10 90 29 10 10 Neutral
    104 29 16 10 121 29 10 10 OK
    135 29 31 10 167 29 10 10 Perfect
    4 9 49 150 10 How hard did you find the problems?
    9 59 42 10 52 59 10 10 Very hard
    66 59 22 10 89 59 10 10 Hard
    103 59 23 10 127 59 10 10 Easy
    141 59 27 10 169 59 10 10 Trivial
    5 9 109 182 10 Which programming languages did you use?
    9 119 22 10 32 119 10 10 Java
    46 119 9 10 56 119 10 10 C
    70 119 20 10 91 119 10 10 C++
    105 119 31 10 137 119 10 10 Python
    151 119 14 10 166 119 10 10 C#
    0 50 35 0
    210 105 180 150
    0 113 27 150
    
    Expected output
    Rate your contest experience: Terrible
    How hard did you find the problems?:
    Which programming languages did you use?: Java; C#
    
  2. Example 2

    Input
    100 100 1 1
    1 5 5 60 10 Do you agree?
    5 25 20 10 30 25 10 10 Yes
    0 31 26 0
    
    Expected output
    Do you agree?: Yes