Under construction

Still being built. Things may change

The Dragon and the Knights

Time limit3sMemory limit128 MB

Summary
Given n lines forming an arrangement with m marked points, determine whether every region of the arrangement contains at least one marked point.
Level

Medium7 of 10

Topics
Geometry, Hash map, Math
Solved
No attempts yet

Problem

A dragon has moved into the Kingdom of Bytes and now threatens its districts.

The kingdom is the Euclidean plane. There are n rivers, and each river flows along an infinite straight line. No two rivers follow the same line, and no three rivers pass through a common point (two rivers may, however, be parallel). Together the rivers cut the plane into connected districts.

There are m knights. Each knight stands at a fixed point (never on a river) and defends the district that contains that point. Two knights may stand at the same point. The dragon never attacks a district that contains at least one knight, but it will attack any district with no knight inside.

Given the rivers and the positions of the knights, decide whether every district is defended.

Input

The first line contains the number of test cases T. Each test case is given as follows:

  • A line with two integers n and m (1≤n≤1001 \le n \le 100, 1≤m≤50 0001 \le m \le 50\,000): the number of rivers and the number of knights.
  • n lines follow; the j-th contains three integers AjA_j, BjB_j, CjC_j (each of absolute value at most 10 00010\,000), the coefficients of the line Aj⋅x+Bj⋅y+Cj=0A_j \cdot x + B_j \cdot y + C_j = 0 along which river j flows.
  • m lines follow; the i-th contains two integers XiX_i, YiY_i (−109≤Xi,Yi≤109-10^9 \le X_i, Y_i \le 10^9), the position of knight i. No knight lies on a river.

No two rivers lie on the same line, and no three rivers share a common point.

Output

For each test case, print a single line: PROTECTED if every district contains at least one knight, and VULNERABLE otherwise. Print the answers in the same order as the test cases appear in the input.

Examples5

  1. Example 1

    Input
    2
    3 7
    0 1 0
    1 0 0
    1 1 -3
    1 1
    5 -1
    3 2
    2 -2
    -2 6
    -1 -2
    -8 4
    1 1
    0 1 0
    0 1
    
    Expected output
    PROTECTED
    VULNERABLE
    
  2. Example 2

    Input
    1
    1 2
    0 1 0
    0 5
    0 -5
    
    Expected output
    PROTECTED
    
  3. Example 3

    Input
    1
    1 2
    0 1 0
    0 5
    0 3
    
    Expected output
    VULNERABLE
    
  4. Example 4

    Input
    1
    2 4
    1 0 0
    0 1 0
    1 1
    -1 1
    -1 -1
    1 -1
    
    Expected output
    PROTECTED
    
  5. Example 5

    Input
    1
    2 3
    1 0 0
    0 1 0
    1 1
    -1 1
    -1 -1
    
    Expected output
    VULNERABLE