Compsoc Progcomp

Problem 1

Deadline Passed

The Problem

We will be simulating a game of cat and mouse. In this game cats, mice and dogs are represented as points in a 2D plane. A mouse is safe if its within a triangle formed by three dogs, and eaten if it isn't safe and within a triangle of three cats. The status of the mouse is undetermined if its neither safe nor eaten. A triangle is represented by 3 points, and a point is considered within the triangle if it is either inside or on the boundary of the triangle.

In the following diagram circles represent dogs, squares cats and triangles mice. Mice A and B are safe, C has unfortunately been eaten and D is neither. The input for this program will consist of a set of dogs and cats and several mouse queries. You must output whether each mouse has been eaten, is safe or if their future lies in the hands of fate.

Input

The input consists of several data sets. The first line of each data set contains three non-negative integers d, c, and m: the number of dogs, cats, and mice, respectively. The next d lines contain the (x, y) coordinates of each dog, one per line. The next c lines contain the (x, y) coordinates of each cat, one per line. The next m lines contain the (x, y) coordinates of each mouse, one per line. Your program must stop processing input when it encounters a data set in which d, c, and m are all zero. All coordinates are integers. Please also note that there may be any (finite) number of input data sets.

Output

Output for each data set begins with a line identifying the data set. For each mouse in the data set, output the line

Mouse at (x,y) is status.

where (x,y) is the location of the mouse from the input and status is one of safe, eaten, or neither. Follow the format given in the Sample Output. Leave a blank line after the output from each data set.

Sample Input

3 3 2
0 0
10 0
0 10
20 20
20 0
0 20
5 5
15 15
3 3 1
0 0
10 0
0 10
20 20
20 0
0 20
40 40
0 0 0

Sample Output

Data set 1:
Mouse at (5,5) is safe.
Mouse at (15,15) is eaten.

Data set 2:
Mouse at (40,40) is neither.

Details

Completed solutions should be emailed to progcomp@uwcs.co.uk before the 25th March.

Half of the marks for a solution come from performance, and half from code quality. The former is to be judged on a range of inputs. The code quality is based on the opinion of the judges. Common standards are to be adheared to here - for example indentation, appropriate comments and appropriate abstractions/language idioms.