{"raw_statement":[{"iden":"statement","content":"Would you want to fight against bears riding horses? Me neither.\n\nLimak 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.\n\nThe 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.\n\nA 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.\n\nGeneral Limak must assign all horses to warriors, one horse per warrior. The cavalry will consist of n units then.\n\nThe 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?\n\nHelp 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).\n\nYou are given multiple test cases.\n\nThe first line of the input contains one integer T (1 ≤ T ≤ 50), denoting the number of test cases.\n\nFor each test case the first line contains one integer n (2 ≤ n ≤ 42).\n\nThe second line contains n integers w1, w2, ..., wn (1 ≤ wi ≤ 1000), denoting strengths of warriors. The first number is the strength of Bravebeart.\n\nThe third line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 1000), denoting strengths of horses.\n\nFor each test case find the answer and print it in a separate line.\n\nPrint _\"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).\n\nIn the first test case Bravebeart can take a horse of strength 6 to get the unit strength 12·6 = 72.\n\nIn 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.\n\nIn the second test case it's impossible to assign horses to warriors so that Bravebeart's unit is stronger than any other one.\n\n"},{"iden":"input","content":"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."},{"iden":"output","content":"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)."},{"iden":"note","content":"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."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ n_k \\in \\mathbb{Z} $ denote the number of warriors and horses, with $ n_k \\geq 2 $.  \n- Let $ W_k = (w_{k,1}, w_{k,2}, \\dots, w_{k,n_k}) \\in \\mathbb{Z}_{>0}^{n_k} $ be the strengths of warriors, where $ w_{k,1} $ is Bravebeart’s strength.  \n- Let $ H_k = (h_{k,1}, h_{k,2}, \\dots, h_{k,n_k}) \\in \\mathbb{Z}_{>0}^{n_k} $ be the strengths of horses.  \n\nLet $ \\Pi_k $ be the set of all bijections $ \\sigma: \\{1, \\dots, n_k\\} \\to \\{1, \\dots, n_k\\} $, representing assignments of horses to warriors.  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 50 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 2 \\leq n_k \\leq 42 $  \n   - $ 1 \\leq w_{k,i} \\leq 1000 $ for all $ i \\in \\{1, \\dots, n_k\\} $  \n   - $ 1 \\leq h_{k,i} \\leq 1000 $ for all $ i \\in \\{1, \\dots, n_k\\} $  \n\n**Objective**  \nDetermine whether there exists a permutation $ \\sigma \\in \\Pi_k $ such that:  \n$$\nw_{k,1} \\cdot h_{k,\\sigma(1)} > \\max_{i=2}^{n_k} \\left( w_{k,i} \\cdot h_{k,\\sigma(i)} \\right)\n$$  \nIf such a permutation exists, output \"YES\"; otherwise, output \"NO\".","simple_statement":"Given n warriors and n horses, each with a strength value, assign one horse to each warrior. Bravebeart is the first warrior. Can you assign horses so that Bravebeart’s unit (warrior × horse) is strictly stronger than every other unit? Print \"YES\" or \"NO\".","has_page_source":false}