This page is still under construction.

Parts of this page are still being built. What you see may change.

Robbery

Time limit1sMemory limit128 MB

Summary
Given time-stamped rectangular exclusions, find the robber's position at each time step where it is uniquely determined, moving at most one cell per step.
Level

Medium6 of 10

Topics
Dynamic programming, Simulation, Matrix
Solved
No attempts yet

Problem

Inspector Robstop is very angry. Last night a bank was robbed, and the robber has not been caught. This has already happened for the third time this year, even though he did everything in his power to stop the robber: as quickly as possible, every road leading out of the city was blocked so that the robber could not escape. He then asked every resident to watch out for the robber, but the only messages he received were of the form "We don't see him."

This time he has had enough. Inspector Robstop decides to analyze how the robber could have escaped, and he asks you to write a program that takes all the information he could gather and works out where the robber was at each point in time.

The city where the bank was robbed happens to be rectangular. The roads leaving the city are blocked for a period of time tt, and during that period several observations of the form "the robber was not inside rectangle RiR_i at time tit_i" are reported. Assuming that the robber moves at most one unit per time step (staying in place, or moving to one of the four orthogonally adjacent cells), your program must determine the exact position of the robber at every time step where it can be deduced.

Input

The input contains the descriptions of several robberies.

The first line of each description contains three integers WW, HH, tt (1≤W,H,t≤1001 \le W, H, t \le 100), where WW is the width and HH the height of the city, and tt is the length of time the city is locked down. The city is a W×HW \times H grid; the point (1,1)(1, 1) is the upper-left corner and (W,H)(W, H) is the lower-right corner.

The next line contains a single integer nn (0≤n≤1000 \le n \le 100), the number of messages the inspector received. Each of the following nn lines contains five integers tit_i, LiL_i, TiT_i, RiR_i, BiB_i. The integer tit_i is the time at which the observation was made (1≤ti≤t1 \le t_i \le t), and LiL_i, TiT_i, RiR_i, BiB_i are the left, top, right and bottom of the observed rectangular area, respectively (1≤Li≤Ri≤W1 \le L_i \le R_i \le W, 1≤Ti≤Bi≤H1 \le T_i \le B_i \le H). Such a message means that the robber was not inside that rectangle (columns Li≤x≤RiL_i \le x \le R_i, rows Ti≤y≤BiT_i \le y \le B_i) at time tit_i.

The input is terminated by a case with W=H=t=0W = H = t = 0, which must not be processed.

Output

For each robbery, first print the line "Robbery #k:", where kk is the number of the robbery (starting at 1). Then there are three possibilities.

If, considering the messages, it is impossible for the robber to still be in the city, print the line "The robber has escaped."

Otherwise, assume that the robber really is in the city. For every time step at which the exact location can be deduced, print one line of the form "Time step i: The robber has been at x,y.", where ii is the time step, xx is the column and yy is the row. Print these lines in increasing order of time ii.

If nothing can be deduced, print the line "Nothing known." and hope that the inspector will not get even angrier.

Print a blank line after each processed case.

Examples1

  1. Example 1

    Input
    4 4 5
    4
    1 1 1 4 3
    1 1 1 3 4
    4 1 1 3 4
    4 4 2 4 4
    10 10 3
    1
    2 1 1 10 10
    0 0 0
    
    Expected output
    Robbery #1:
    Time step 1: The robber has been at 4,4.
    Time step 2: The robber has been at 4,3.
    Time step 3: The robber has been at 4,2.
    Time step 4: The robber has been at 4,1.
    
    Robbery #2:
    The robber has escaped.