Interesting Scoring Systems
시간 제한1초메모리 제한512 MB
승리에 2점과 3점을 주는 두 기준의 점수가 주어질 때, 선수 0이 토너먼트 그래프의 유일한 출발점이 될 수 있는지 판정한다.
문제
Score in chess tournaments is a controversial topic. Abel likes the classical system: 2 points per win and 1 point per draw. Bolzano prefers the football way: 3 points per win and 1 point per draw. But Cardano doesn't like either way and has his own system to declare a winner. We define the graph of the tournament as the graph where each node represents a player and an edge goes from player to player if player won at least one game against player . Then Cardano states that a player wins the tournament only if in the graph of the tournament there is a path from to everyone else and there is none from any other player to .
Recently, there has been a chess tournament of players, numbered from to . The only information we have is the number of points of each player according to Abel's and Bolzano's criteria. Each player might have played any number of times with any other player. Determine if it is possible that player won the tournament according to Cardano's criteria.
입력
The first line contains one integer , the number of test cases (). Each test case consists of three lines:
The first line of contains one integer (), the number of participants in the tournament.
The second line contains integers (), where is the number of points player has obtained according to Abel's criteria.
The third line contains integers (), where is the number of points player has obtained according to Bolzano's criteria.
The sum of for all test cases won't exceed .
It is guaranteed that the given scoring corresponds to a valid tournament.
출력
For each test case, print a line with the word "YES" if it is possible that player won the tournament according to Cardano's criteria. Otherwise, print a line with the word "NO".