407405: GYM102785 A A lazy controller

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. A lazy controllertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

One of the shops of N-sky machine-building plant produces spare parts for cars. In order to monitor the quality, the weight of every detail is to be controlled. For that there is a special controlling person in charge. Unfortunately, the controller in this checking unit is rather lazy, and instead of weighing every detail separately, he decides to «optimize» the process a little. Also all similar (of the same type) parts are supposed to be of the same weight.

At the end of the working day, a box with many identical parts arrives for inspection. The controller knows that a quality part should weigh a interger number of grams, but is too lazy to look into the documents and find out how much exactly.

The «optimized» control process is as follows:

  1. The controller carries out $$$k$$$ weights, and numbers them from $$$1$$$ to $$$k$$$.
  2. For the $$$i$$$-th weighing, the number $$$a_i$$$ is randomly chosen for the number of parts; this number is recorded in the weights register-book.
  3. The selected number of parts is placed on the scales, and their total weight $$$w_i$$$ is also recorded in the register-book.
  4. Upon completion of $$$k$$$ weighing, the register-book is analyzed and a conclusion is made on the presence or absence of defects.

Naturally, such an «optimized» process does not always reveal the presence of faulty spare parts, and does not indicate a specific defective part. The controller is so lazy that in the event of signs of a defective item rejects the entire batch. In all other cases, the batch receives a sign of quality.

Your task will be to write a program that, according to the weights register-book, will determine whether the batch will receive a quality mark or will be rejected.

Input

The first line of the input file contains an integer $$$k$$$ $$$(1 \le k \le 1000)$$$. Next follow $$$k$$$ number of lines, each of which contains integers $$$a_i$$$ $$$(0 < a_i \le 1000)$$$ and $$$w_i$$$ $$$(0 < w_i < 1000000)$$$, separated by a space.

Output

The output line should contain the word «DEFECT» if there are for sure defective parts in the batch, or «QUALITY» if there are no signs of defective parts.

ExamplesInput
3
10 30
5 15
2 6
Output
QUALITY
Input
2
2 5
4 10
Output
DEFECT
Note

The participant must display «QUALITY» in the event that there are no definite signs of defect, even if there is not enough data for an unambiguous conclusion about the quality of the details

加入题单

算法标签: