Problem: Ashish has n elements arranged in a line. 

These elements are represented by two integers a_i — the value of the element and b_i — the type of the element (there are only two possible types: 0 and 1). He wants to sort the elements in non-decreasing values of a_i.

He can perform the following operation any number of times: 

  * Select any two elements i and j such that b_i ≠ b_j and swap them. That is, he can only swap two elements of different types in one move. 



Tell him if he can sort the elements in non-decreasing values of a_i after performing any number of operations.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains one integer n (1 ≤ n ≤ 500) — the size of the arrays.

The second line contains n integers a_i (1 ≤ a_i ≤ 10^5) — the value of the i-th element.

The third line containts n integers b_i (b_i ∈ \{0, 1\}) — the type of the i-th element.

Output

For each test case, print "Yes" or "No" (without quotes) depending on whether it is possible to sort elements in non-decreasing order of their value.

You may print each letter in any case (upper or lower).

Example

Input


5
4
10 20 20 30
0 1 0 1
3
3 1 2
0 1 1
4
2 2 4 8
1 1 1 1
3
5 15 4
0 0 0
4
20 10 100 50
1 0 0 1


Output


Yes
Yes
Yes
No
Yes

Note

For the first case: The elements are already in sorted order.

For the second case: Ashish may first swap elements at positions 1 and 2, then swap elements at positions 2 and 3.

For the third case: The elements are already in sorted order.

For the fourth case: No swap operations may be performed as there is no pair of elements i and j such that b_i ≠ b_j. The elements cannot be sorted.

For the fifth case: Ashish may swap elements at positions 3 and 4, then elements at positions 1 and 2.

Solution (in PYTHON3):

Solution:
#CF 644 (DIV-3)
 
    

'''test=int(input())
for i in range(test):
    a,b=[int(i) for i in input().split()]
    k=min(a,b)
    if 2*k>=max(a,b):
        print((2*k)**2)
    else:
        print((max(a,b))**2)'''
            
'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    ans=float("inf")
    for i in range(n-1):
        res=float("inf")
        for j in range(i+1,n):
            res=min(res,abs(arr[i]-arr[j]))
        ans=min(ans,res)
    print(ans)'''

'''test=int(input())

for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    even=0
    odd=0
    for i in range(n):
        if arr[i]%2:
            odd+=1
        else:
            even+=1
    if even%2!=odd%2:
        print("NO")
    else:
        if even%2==0 and odd%2==0:
            print("YES")
        else:
            flag=0
            for i in range(n-1):
                for j in range(i+1,n):
                    if arr[i]%2!=arr[j]%2 and abs(arr[i]-arr[j])==1:
                        flag=1
                        break
            if flag:
                print("YES")
            else:
                print("NO")'''



'''test=int(input())
def check(t):
    i=2
    ans=set()
    while i**2<=t:
        if t%i==0:
            ans.add(i)
            ans.add(n/i)
            
        i+=1
    if t>1:
        ans.add(t)
    return ans

for i in range(test):
    n,k=[int(i) for i in input().split()]
    if k>=n:
        print(1)
    else:
        flag=1
        a=[i for i in sorted(check(n),reverse=True)]
        ans=float("inf")
        for i in a:
            if i<=k:
                ans=min(ans,int(n/i))
                
        if ans!=float("inf"):
            print(ans)
        else:
            print(n)'''
            
'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[ 0 for i in range(n)]
    
    for i in range(n):
        arr[i]=[int(i) for i in input()]
    #print(arr)
    flag=1
    for i in range(n):
        for j in range(n):
            if arr[i][j]:
                if i==n-1 or j==n-1:
                    continue
                else:
                    if (arr[i+1][j] or arr[i][j+1]):
                        continue
                    else:
                        flag=0
                        break
        if not flag:
            break
    #print(flag)
    if not flag:
        print("NO")
    else:
        print("YES")'''

#CF 642(DIV-2)

'''test=int(input())
for i in range(test):
    n,m=[int(i) for i in input().split()]
    k=max(n,m)
    t=min(n,m)
    if k%2:
        ans=(k-1)*0.5*t+(t//2 +t%2)
    else:
        ans=(k/2)*t
    print(int(ans))
'''
'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    arr.sort()
    dp=[0]*(n)
    ans=1
    last=0
    for i in range(n):
        if ans + i>=arr[i]:
            dp[i]=1
            last=i+1

    print(ans+last)'''

'''test=int(input())
for i in range(test):
    x1,y1,x2,y2=[int(i) for i in input().split()]
    if x1==x2 or y1==y2:
        print(1)
    else:
        path=1
        n=x2-x1
        m=y2-y1
        print(m*n+1)'''

# Educational round
'''test=int(input())
for i in range(test):
    n,m,k=[int(i) for i in input().split()]
    cards=n//k
    if cards>=m:
        print(m)
    else:
        rem=m-cards
        if rem%(k-1)==0:
            ans=cards-(rem//(k-1))
        else:
            ans=cards-(rem//(k-1) +1)
        print(ans)'''

'''test=int(input())
for i in range(test):
    n,m,x,y=[int(i) for i in input().split()]
    arr=[0]*(n)
    for i in range(n):
        arr[i]=[i for i in input()]
    dp=[[0 for j in range(m)] for k in range(n)]
    price=0
    #print(arr)
    #print(dp)
    for i in range(n):
        for j in range(m):
            if arr[i][j]=="." and not dp[i][j]:
                if j+1<m and arr[i][j+1]==".":
                    if 2*x<=y:
                        dp[i][j]=1
                        dp[i][j+1]=1
                        price+=2*x
                    else:
                        dp[i][j]=1
                        dp[i][j+1]=1
                        price+=y
                else:
                    dp[i][j]=1
                    price+=x
    print(price)
'''
'''test=int(input())
import math
for i in range(test):
    h,c,t=[int(i) for i in input().split()]
    quant=(t-c)/(h-c)
    if t==(h+c)/2:
        print(2)
    elif h==t:
        print(1)
    elif c==t:
        print(2)
    else:
        #print(quant)
        ans=math.ceil(quant/(2*quant-1))
        print(int(2*ans-1))
'''
'''n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n)
max_=[]
for i in range(n):
    res=float("-inf")
    sum1=0
    while max_ and arr[max_[-1]]<=arr[i]:
        #print(max_)
        t=arr[max_.pop()]
        sum1+=t
        res=max(res,sum1)
    dp[i]+=max(res,0)
    max_.append(i)
min_=[]
for j in range(n-1,-1,-1):
    res2=float("-inf")
    sum_=0
    while min_ and arr[min_[-1]]<=arr[j]:
        k=arr[min_.pop()]
        sum_+=k
        res2=max(res2,sum_)
    min_.append(j)
    dp[j]+=max(res2,0)
    


print(max(dp))
'''

# CF 646-DIV-2 Bahut Kharab

'''test=int(input())
for i in range(test):
    n,x=[int(i) for i in input().split()]
    arr=[int(i) for i in input().split()]
    even=0
    odd=0
    for i in arr:
        if i%2:
            odd+=1
        else:
            even+=1
    if odd%2==0:
        odd-=1
    if odd>0 and (x%2==1 or even>0) and odd+even>=x:
        ans="YES"
    else:
        ans="NO"

    print(ans)'''

'''test=int(input())
for i in range(test):
    s=input()
    c0=0
    c1=0
    for i in s:
        if i=="0":
            c0+=1
        else:
            c1+=1
    ans=min(c1,c0)
    n1=0
    n0=0
    for i in range(len(s)):
        if s[i]=="1":
            n1+=1
            c1-=1
        else:
            n0+=1
            c0-=1
        #print(c0,c1,n0,n1)
        ans=min(ans,c0+n1)
        ans=min(ans,c1+n0)
    
    print(ans)'''

'''test=int(input())
from collections import defaultdict
def dfs(c,p,level):
    level[c]=level[p]+1
    for i in graph[c]:
        if i!=p:
            dfs(i,c,level)

for i in range(test):
    n,x=[int(i) for i in input().split()]
    graph=defaultdict(list)
    level=[0]*(n+1)
    for i in range(n-1):
        p,c=[int(i) for i in input().split()]
        graph[p].append(c)
        graph[c].append(p)
    leaf=0
    if len(graph[x])==1:
        leaf=1
    else:
        leaf=0
    if n==1  or leaf:
        print("Ayush")
    elif n%2:
        print("Ashish")
    else:
        print('Ayush')'''

# CF-647 DIV-2

'''test=int(input())
def pow(a):
    cnt=0
    while a%2==0:
        a=a/2
        cnt+=1
    return [int(a),cnt]
for i in range(test):
    a,b=[int(i) for i in input().split()]
    ans=0
    first=pow(a)
    second=pow(b)
    print(first,second)
    print(second[0]/first[0])
    if a==b:
        ans=0
    elif first[0]!=second[0]:
        ans=-1
    else:
        diff=abs(first[1]-second[1])
        ans=0
        k=diff//3
        diff=diff%3
        ans+=k
        if diff==2:
            ans+=1
        elif diff==1:
            ans+=1
        

    print(ans)'''

'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    t=max(arr)
    bits=0
    while t:
        t=t>>1
        bits+=1
    dp=[0]*(bits)
    if n%2==0:
        for i in range(bits):
            cnt=0
            for j in arr:
                if j&(1<<i):
                    cnt+=1
            if cnt==n/2:
                dp[i]=1
        ans=0
        for k in dp:
            if k:
                ans+=2*i
                break
    else:
        ans=-1
    print(dp)'''

    
'''n,m=[int(i) for i in input().split()]
from collections import defaultdict
graph=defaultdict(list)
for i in range(m):
    p,c=[int(i) for i in input().split()]
    graph[p].append(c)
    graph[c].append(p)


ans=[float("inf")]*(n+1)
dir_=[0]*(n+1)
lev[1]=0
visited=[0]*(n+1)
def dfs(c):
    visited[c]=1
    for i in graph[c]:
        if visited[i]=
        
bfs(1)

print(dir_)
if 0 in dir_[2:]:
    print("No")
else:
    print("Yes")
    for j in dir_[2:]:
        print(j)'''

# CF-648 DIV-2
'''test=int(input())
for i in range(test):
    claim_r=set()
    claim_c=set()
    cnt=0
    n,m=[int(i) for i in input().split()]
    dp=[[]]*(n)
    for i in range(n):
        dp[i]=[int(j) for j in input().split()]
        for j in range(m):
            if not dp[i][j]:
                if i not in claim_r and j not in claim_c:
                    cnt+=1
                    claim_r.add(i)
                    claim_c.add(j)

            else:
                claim_r.add(i)
                claim_c.add(j)
    #print(cnt)
    if cnt%2:
        print("Ashish")
    else:
        print("Vivek")'''
test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    arr_b=[[arr[i],b[i]] for i in range(n)]
    arr_b.sort(key=lambda x:x[0])
    k=0
    ans="Yes"
    alpha={(1,0):0,(0,1):0,(1,1):0,(0,0):0}
    for i in range(n):
        k=(b[i],arr_b[i][1])
        if k in alpha:
            alpha[k]+=1

    if alpha[(1,0)]!=alpha[(0,1)]:
        print("No")
    elif alpha[(1,1)]==n or alpha[(0,0)]==n:
        if arr==[i[0] for i in arr_b]:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")