A highway and the seven dwarfs
题号:NC233738
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Once upon a time, there was a land where several families of dwarfs were living. This land was called Dwarfland. Each family lived in one house. Dwarfs were often visiting their friends from the other families. Because the Dwarfland was free of evil, it happened that each dwarf visited each other during some short period of time.

Once, the humans living in countries around Dwarfland decided to build several straight highways. As the humans weren't aware of the dwarfs, some of the planned highways passed through Dwarfland. The dwarfs discovered this and were quite unhappy about it. The dwarfs are very little, and also very slow, so they are unable to cross the highway safely.

The dwarfs managed to get the plans for the highways somehow, and now they need your help. They would like to keep on visiting each other, so they don't like those highways which divide their houses into two non-empty parts. After they find out which highways they don't like, they will magically prevent the humans from building them.

The dwarfs are very little, and cannot reach the keyboard. So they asked for your help.

Task

Given is a number N of points (houses) in the plane and several straight lines (highways). For each given line, your task is to determine whether all N points lie on the same side of the line or not. Your program has to output the answer for the currently processed line before reading the description of the next one. You may assume that no highway passes through any of the houses.

输入描述:

Your program is supposed to read the input from the standard input and write its output to the standard output. The first line of the input contains one integer N . N lines follow, the i-th of them contains two integers x_i, y_i  separated by a single space - the coordinates of the i-th house.

Each of the following lines contains four integers X_1, Y_1, X_2, Y_2 separated by a single space. These numbers are the coordinates of two different points and , lying on the highway.

输出描述:

For each line of input, your program is supposed to output a line containing the string "GOOD" if all of the given points are on the same side of the given line, or "BAD" if the given line divides the points.
示例1

输入

复制
4
0 0
6 0
3 4
4 0
5 3 7 0
4 -4 7 4
4 47 4 94

输出

复制
GOOD
BAD
BAD