Stapler

면접 대비

시간 제한2초메모리 제한2048 MB

요약
축에 평행한 화면 사각형과 두 스테이플 지점을 잇는 선분이 주어질 때, 선분이 사각형의 경계를 포함해 교차하는지 판정한다.
난이도

보통10점 중 5점

유형
기하, 구현, 수학, 구간
정답자
아직 제출이 없습니다

문제

Alice is selling a new model of game console in the toy store. When selling a new console, Alice uses a stapler to attach the receipt to the box.

However, the stapler pierces the box at two points, causing damage along the entire line segment between those two points. If any part of this segment (including its endpoints) overlaps with the console’s screen (including its boundary), it will be damaged and Alice must compensate for the console.

Fortunately, a laser reveals the exact position of the screen inside the box. The game console’s screen is a rectangle with sides parallel to the coordinate axes. Its bottom-left corner is at (x_l,y_l)(x\_l , y\_l) and its top-right corner is at (x_r,y_r)(x\_r, y\_r).

Alice plans to staple the box at the points (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2). Please help her determine whether the stapler will damage the screen. If it will, stop her immediately.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt. The description of the test cases follows.

The first line of each test case contains four integers x_lx\_l, y_ly\_l, x_rx\_r, y_ry\_r, representing the coordinates of the bottom-left and top-right corners of the screen.

The second line of each test case contains four integers x_1x\_1, y_1y\_1, x_2x\_2, y_2y\_2, representing the coordinates of the expected stapler penetration positions.

출력

For each test case, print STOP on a line if Alice will damage the screen, and print OK otherwise.

제한

  • $1 ≤ t ≤ 10^4
  • The area of the screen is greater than 00.
  • The length of the stapler is greater than 00.
  • All coordinates are integers with absolute value at most 10410^4.

예제1

  1. 예제 1

    입력
    3
    0 0 5 5
    0 10 10 0
    0 0 5 5
    6 6 6 7
    0 0 5 5
    1 1 2 2
    
    예상 출력
    STOP
    OK
    STOP