403357: GYM101138 E Bravebeart

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

Description

E. Bravebearttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Would you want to fight against bears riding horses? Me neither.

Limak is a grizzly bear. He is a general of the dreadful army of Bearland. The most important part of an army is the cavalry of course.

The cavalry of Bearland consists of n warriors and n horses, both numbered 1 through n. Limak knows the strength of each warrior w1, w2, ..., wn and of each horse h1, h2, ..., hn.

A warrior together with his horse is called a unit. The strength of a unit is equal to the multiplied strengths of a warrior and a horse.

General Limak must assign all horses to warriors, one horse per warrior. The cavalry will consist of n units then.

The first warrior (the one with the strength w1) is called Bravebeart. He is always the first to charge the enemy. Limak decided that Bravebeart deserves some respect and his unit must be the strongest one, with no ties allowed. But is it possible?

Help Limak and check whether there is an assignment of horses to warriors for which the Bravebeart's unit is strictly stronger than any other unit. Print "YES" or "NO" (without the quotes).

Input

You are given multiple test cases.

The first line of the input contains one integer T (1 ≤ T ≤ 50), denoting the number of test cases.

For each test case the first line contains one integer n (2 ≤ n ≤ 42).

The second line contains n integers w1, w2, ..., wn (1 ≤ wi ≤ 1000), denoting strengths of warriors. The first number is the strength of Bravebeart.

The third line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 1000), denoting strengths of horses.

Output

For each test case find the answer and print it in a separate line.

Print "YES" (without the quotes) if there is an assignment where the strength of the Bravebeart's unit is strictly greater than strength of any other unit. Otherwise print "NO" (without the quotes).

ExampleInput
2
6
12 9 7 1 20 10
3 6 4 7 5 5
4
5 17 10 1
200 400 800 600
Output
YES
NO
Note

In the first test case Bravebeart can take a horse of strength 6 to get the unit strength 12·6 = 72.

In one way of assigning other horses to warriors the pairs (strength of warrior, strength of horse) are: (9, 7), (7, 5), (1, 5), (20, 3), (10, 4). Units strengths would be 63, 35, 5, 60 and 40, respectively. Indeed, the Bravebeart's unit is stronger than any other unit then.

In the second test case it's impossible to assign horses to warriors so that Bravebeart's unit is stronger than any other one.

加入题单

上一题 下一题 算法标签: