This page is still under construction.

Parts of this page are still being built. What you see may change.

Teleports

Interview

Time limit2sMemory limit256 MB

Summary
Given n points, each teleport reflects your position across it; decide whether you can reach the target point from the start.
Level

Medium6 of 10

Topics
Graph, BFS, Geometry, Hash map
Solved
No attempts yet

Problem

He who visits friends in the morning acts wisely! Following exactly this rule, the boy Vasya decided to visit his friend Petya. Walking there is too easy, so it is time to test an innovative teleport system, Vasya thought. The city has n teleports that work in a strange way: the i-th teleport has coordinates (xi, yi), and when you try to use it from a point (x, y), the user ends up at the point (2xi − x, 2yi − y), that is, the point symmetric to the starting point with respect to the teleport.

Help Vasya find out whether he can get from his house at the point (xs, ys) to Petya's house at the coordinates (xf, yf).

Input

The first line contains one positive integer t, the number of test cases in the input. The descriptions of the test cases follow.

The description of each test case consists of n + 3 lines. The first line contains one integer n (1 ≤ n ≤ 105), the number of teleports.

The next n + 2 lines contain two integers x, y each (−103 ≤ x, y ≤ 103): the coordinates of the n teleports, Vasya's house, and Petya's house, respectively. No two teleports coincide.

The sum of n over all test cases does not exceed 105.

Output

For each test case, on a separate line, output «YES» if Vasya can get to Petya, otherwise output «NO».

Examples1

  1. Example 1

    Input
    2
    4
    1 1
    -1 1
    -1 -1
    1 -1
    0 0
    4 0
    2
    0 0
    12 36
    0 0
    12 36
    
    Expected output
    YES
    NO