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.
#!/usr/bin/env python
# coding: utf-8

# In[4]:


# import math
# for i in range(int(input())):
#     a,b=map(int,input().split())
#     if a%b==0 or a%b<=1.5:
#         print(a)
#     else:
#         no=int(a/b)
#         no+=.5
#         print(math.floor(b*no))


# In[10]:


# import math
# for i in range(int(input())):
#     a,b=map(int,input().split())
#     frac,asd=math.modf(a/b)
#     if a%b==0 or frac<=.5:
#         print(a)
#     else:
#         no=int(a/b)
#         no+=.5
#         print(int(b*no))


# In[4]:


# n=int(input())
# s=input()
# d={}
# a=0
# for i in range(n-1):
#     a=s[i]+s[i+1]
#     if d.get(a):
#         d[a]+=1
#     else:
#         d[a]=1
# max_key = max(d, key=d.get)
# print(max_key)
    
    


# In[ ]:


# n,k=map(int,input().split())
# a=list(map(int,input().split()))
# a.sort()
# if k==0 and a[0]==0:
#     print(-1)
# elif k==0 and a[0]==1:
#     print(-1)
# elif k==0:
#     print(a[0]-1)
# elif  len(a)>1  and k!=n and a[k]==a[k-1] :print(-1)
# else:print(a[k-1])


# In[1]:


# n=int(input())
# a=list(map(int,input().split()))
# k=0
# while k<n:
#     for i in range(n):
#         f=1
#         if a[i]==-1:pass
#         elif a[i]%3==0:
#             for j in range(n):
#                 if a[j]==a[i]//3:
#                     print(a[i],end=' ')
#                     print(a[j],end=' ')
#                     a[i],a[j]=-1,-1
#                     f=0
#                     k+=1
#                     break
# #             if f :
# #                 for j in range(n):
# #                 if a[j]==a[i]*2:
# #                     print(a[i],end=' ')
# #                     print(a[j],end=' ')
# #                     a[i],a[j]=-1,-1
# #                     f=0
# #                     k+=1
#             break
        
#     for i in range(n):
#         f=1
#         if a[i]==-1:pass
#         elif a[i]%2==0:
#             for j in range(n):
#                 if a[j]==a[i]*2:
#                     print(a[i],end=' ')
#                     print(a[j],end=' ')
#                     a[i],a[j]=-1,-1
#                     f=0
#                     k+=1
#                     break
                    
#             break


# In[15]:


# n=int(input())
# a=list(map(int,input().split()))
# d={}
# lis=[]
# for i in a:
#     if d.get(i):pass
#     else:
#         d[i]=1
# l=len(d)
# while l>0:
#     if d[a[n-1]]:
#         lis.append(a[n-1])
#         d[a[n-1]]=0
#         l-=1
#     n-=1

# lis.reverse()
# print(len(d))
# for i in lis:
#     print(i,end=" ")
        


# In[20]:


# n=int(input())
# s=input()
# ans,c=0,0
# for i in s:
# #     print(i,c)
#     if i=='x':
#         c+=1
#     else:
#         if c>=3:ans+=c-2
#         c=0
# if c>=3:ans+=c-2
# print(ans)


# In[24]:


# n,k=map(int,input().split())
# a=list(map(int,input().split()))
# t=list(map(int,input().split()))
# s=0
# for i in range(n):
#     a[i]+=s
#     s=a[i]
    

# for i in t:

#     for j in range(n):
#         if j==0 and a[j]>=i:
#             print(1,abs(i))
#             break
            
#         elif a[j]>=i:
#             print(j+1,abs(a[j-1]-i))
#             break


# In[24]:


# a=[10,25,37]
# n=3
# def bsearch(no):
#     low=0
#     high=n
#     mid=(low+high)//2
#     while high-low>1:
#         if a[mid]==no:return mid
#         print(high,low,mid)
#         if no>a[mid]:low=mid
#         elif no<a[mid]:high=mid
#         mid=(low+high)//2
#     return high

# print(bsearch(12))


# In[ ]:



# n,k=map(int,input().split())
# a=list(map(int,input().split()))
# t=list(map(int,input().split()))

# def bsearch(no):
#     low=0
#     high=n
#     mid=(low+high)//2
#     while high-low>1:
#         if a[mid]==no:return mid
#         # print(high,low,mid)
#         if no>a[mid]:low=mid
#         elif no<a[mid]:high=mid
#         mid=(low+high)//2
#     return high
    
# s=0
# for i in range(n):
#     a[i]+=s
#     s=a[i]
    

# for i in t:
    
#     if i<=a[0]:
#         print(1,abs(i))
#     else:
#         j=bsearch(i)
#         print(j+1,abs(i-a[j-1]))


# In[ ]:


# for test_case in range(int(input())):
#     n,k=map(int,input().split())
#     s=input()
#     c,ans=0,0
#     for i in s:
#         if i=='0':
#             c+=1
#             if c==(2*k)+1:
#                 ans+=1
#                 c=0
#     if c==(2*k)+1:
#                 ans+=1
#                 c=0
#     print(ans)
                
        
        
    


# In[ ]:


# for test_case in range(int(input())):
#     n=int(input())
#     a=list(map(int,input().split()))
#     a.sort()
#     ans=1000000000
#     for i in range(n-1):
#         ans=min(ans,abs(a[i+1]-a[i]))
#     print(ans)


# In[1]:


# for test_case in range(int(input())):
#     n=int(input())
#     a=list(map(int,input().split()))
#     a.sort()
#     i,d=0,{}
#     par,p,o=0,0,0
#     for i in a:
#         # print(p,o)
#         if d.get(i-1):
#             # print("yahh",i,"asd")
#             # print(i)
#             d[i-1]-=1
#             if i %2==0:o-=1
#             else:p-=1
            
            

#         elif i%2==0:
#             if d.get(i) or d.get(i)==0:d[i]+=1
#             else:d[i]=1
#             p+=1
#         else:
#             if d.get(i) or d.get(i)==0:d[i]+=1
#             else:d[i]=1
#             o+=1
        
        
        
#     if o%2!=0 or p%2!=0:print("NO")
#     else :print("YES")


# In[ ]:


# for i in range(int(input())):
#     n,k=map(int,input().split())
#     f=1
#     if k ==1:
#         print(n)
#         f=0
#     elif k>=n:
#         print(1)
#         f=0
#     else:
#         for i in range(2,int(n**.5)+1):
#             if n%i==0 and i<=k and n//i<=k:
#                 print(min(i,n//i))
#                 f=0
#                 break
#     if f:print(n)


# In[1]:


# n,k=map(int,input().split())
# S=[input().strip() for i in range(n)]
# SET=set(S)
# ANS=0
 
# for i in range(n-1):
#     for j in range(i+1,n):
        
#         rest=''
#         for l in range(k):
#             if S[i][l]==S[j][l]:
#                 rest+=S[i][l]
#             else:
#                 rest+=chr(236-ord(S[i][l])-ord(S[j][l]))
 
#         if rest in SET:
#             ANS+=1
# print(ANS//3)


# In[5]:


# n=int(input())
# a=list(map(int,input().split()))
# d={}
# l=[]
# nu=1
# f=1
# for i in range(1,31):
#     l.append(2**i)
# ans=0    

# for i in a:
#     if d.get(i)==None:d[i]=1
#     else:d[i]+=1
# for i in a:
#     # print(ans,f)
#     f=1
#     for j in l:
#         if d.get(j-i):
#             if j==i*2 :
#                 if d.get(j-i)>=2:
#                     f=0
#             else:
#                 f=0
#                 break
#     if f :ans+=1
        
# print(ans)
    



# In[12]:


for t in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    b=list(map(int,input().split()))
    if (all(l[i] <= l[i+1] for i in range(len(l)-1))):
           print("YES")
    elif b.count(1)>0 and b.count(0)>0:print('YES')
    else:print("NO")


# In[6]:





# In[3]:





# In[ ]:




