Chandu and Game

0

0 votes
Very-Easy
Problem

Chandu and Amit are playing a game which consists of two sequences of integers, namely A and B, each having length N. Binary representation of each integer of sequence A contains only one set bit. Initially, both of them are having score of 1 point each.Each one has to select an interval (continuous subsegment) of sequence A and if interval chosen is [u,v], then each integer A[i] between indexes u and v (both included) will be either multiplied or divided to the score depending on whether B[i] is 1 or -1 respectively. One who gets the maximum score wins the game. Amit has already chosen an interval [L,R]. Its chandu's turn now and since he is feeling sleepy (he always feels sleepy), he needs your help to figure out whether he can win or not.

Input Format-

First line consists of an integer T, i.e., number of test cases.

Each case consists of an integer N in the first line.

Second line consists of Sequence A.

Third line consists of sequence B.

Fourth line consists of two integers L and R.

Note-- Binary representation of each integer of sequence A contains only one set bit.

Note-- Indexing of both sequences is 1-based.

Output Format-

For each test case, output "YES"(without quotes) if it is possible for chandu to win, else print "NO"(without quotes) in separate lines.

Constraints-

1 <= T <= 10

1 <= N <= 10^5

2 <= A[i] <= 2*10^18

-1 <= B[i] <= 1

1 <= L <= R <= N

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For first case, Amit's score is 256 which is the maximum possible, hence there is no possibility of Chandu's win.

For second case, Amit's score is 8, Chandu can win by choosing interval [1,3] and his score will be 256.

Note that this is just one of the winning cases, there are other intervals for which Chandu can win.

Editor Image

?