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 \ne 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 \le t \le 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 \le n \le 500)$ — the size of the arrays.

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

The third line containts $n$ integers $b_i$ $(b_i \in \{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 \ne 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$.

Difficulty: interview

Starter code:

Solutions:
t = int(input())

for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    if list(sorted(a)) == a or not all(x == b[0] for x in b):
        print("Yes")
    else:
        print("No")


t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    if 0 < sum(b) < len(b):
        print("Yes")
    else:
        if a == sorted(a):
            print("Yes")
        else:
            print("No")


from sys import stdin
input = stdin.readline

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    if len(set(b)) == 2:
        print('Yes')
        continue

    if a == sorted(a):
        print('Yes')
    else:
        print('No')

def read_int():
    return int(input())


def read_ints():
    return list(map(int, input().split(' ')))


t = read_int()
for case_num in range(t):
    n = read_int()
    a = list(read_ints())
    b = list(read_ints())
    tot = sum(b)
    c = list(a)
    c.sort()
    if c == a:
        print('Yes')
    else:
        print('No' if tot == 0 or tot == n else 'Yes')


from bisect import bisect_left as lower_bound, bisect_right as upper_bound
from sys import stdin, stdout
from collections import defaultdict

def solve(arr, n):
    pass

def main():
    t = int(input())

    for _ in range(t):
        n = int(input())
        a = list(map(int, input().strip().split()))
        b = list(map(int, input().strip().split()))

        if len(set(b)) == 1:
            if sorted(a) == a: print("Yes")
            else: print("No")

        else: print("Yes")


def __starting_point(): main()

__starting_point()

t = int(input())

for _ in range(t):
    n = int(input())
    arr1 = [int(x) for x in input().split()]
    arr2 = [int(x) for x in input().split()]
    tmp  =sum(arr2)
    if tmp==0 or tmp==n:
        if sorted(arr1) == arr1:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")

def solve(n, A, B):
    if A == sorted(A):
        return True
    if len(set(B)) == 2:
        return True
    return False


def main():
    T = int(input())
    for _ in range(T):
        n = int(input())
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
        print("Yes" if solve(n, A, B) else "No")


def __starting_point():
    main()

__starting_point()

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    j = a.copy()
    a.sort()
    if 1 in b and 0 in b:
        print('Yes')
    elif j == a:
        print('Yes')
    else:
        print('No')

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    if a == sorted(a):
        print('Yes')
    else:
        ch0 = 0
        ch1 = 0
        for i in b:
            if i == 0:
                ch0 += 1
            else:
                ch1 += 1
        if ch1 == 0 or ch0 == 0:
            print('No')
        else:
            print('Yes')

for _ in range(int(input())):
    n = int(input())
    aa = list(map(int, input().split()))
    bb = set(map(int, input().split()))
    ans = len(bb) > 1 or aa == sorted(aa)
    print('Yes' if ans else 'No')


T = int(input())
for t in range(T):
    n = int(input())
    A = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = sum(b)
    if s != 0 and s != n:
        print("Yes")
    else:
        if sorted(A) == A:
            print("Yes")
        else:
            print("No")


import sys
input = sys.stdin.readline

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    out = 0
    for i in range(n - 1):
        if b[i] != b[i + 1]:
            out = 1

    sort = 1
    for i in range(n - 1):
        if a[i] > a[i + 1]:
            sort = 0

    if out or sort:
        print('Yes')
    else:
        print('No')


from collections import deque
from sys import stdin, stdout  
import math
input = stdin.readline
#print = stdout.write

for _ in range(int(input())):
    n = int(input())
    arr = list(map(int, input().split()))
    types = list(map(int, input().split()))
    if types.count(1) and types.count(0):
        print('Yes')
    else:
        if sorted(arr) == arr:
            print('Yes')
        else:
            print('No')


t = int(input())
for qwe in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if (min(b) != max(b)):
		print("Yes")
	else:
		if list(sorted(a)) == a:
			print("Yes")
		else:
			print("No")

t=int(input())
for _  in range(t):
    n=int(input())
    aa=list(map(int,input().split()))
    bb=list(map(int,input().split()))
    st=0
    ac=[aa[i] for i in range(n) if bb[i]==0]
    bc=[aa[i] for i in range(n) if bb[i]==1]
    if(len(ac)==0 or len(bc)==0):
        if(len(ac)==0):
            if(bc!=sorted(bc)):
                print("No")
            else:
                print("Yes")
        else:
            if(sorted(ac)!=ac):
                print("No")
            else:
                print("Yes")
            
    else:
        print("Yes")
        
    


for _ in range(int(input())):
    n = int(input())
    arr = list(map(int, input().split()))
    typ = list(map(int, input().split()))

    if len(set(typ)) == 2:
        print("Yes")
        continue

    prev = -1
    flag = True
    for e in arr:
        if e < prev:
            flag = False
            break
        prev = e

    if flag:
        print("Yes")
    else:
        print("No")



t = int(input())

for T in range(t):
    n = int(input())

    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]

    if 0 in b and 1 in b:
        print("Yes")
    else:
        Yes = True
        for i in range(1,n):
            if a[i] < a[i - 1]:
                Yes = False
                break
        if Yes:
            print("Yes")
        else:
            print("No")




def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    if a == sorted(a):
        print("Yes")
        return
    tp = b[0]
    if (tp - 1) % 2 in b:
        print("Yes")
    else:
        print("No")



def __starting_point():
    t = int(input())
    for i in range(t):
        main()

__starting_point()

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    x = []
    y = []
    for i in range(n):
        if b[i] == 0:
            x.append(a[i])
        else:
            y.append(a[i])
    if len(x) == 0:
        if y == sorted(y):
            print("Yes")
        else:
            print("No")
    elif len(y) == 0:
        if x == sorted(x):
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")
        '''
        x.sort()
        y.sort()
        merged = []
        i = 0
        j = 0
        for elem in b:
            if elem == 0:
                merged.append(x[i])
                i += 1
            else:
                merged.append(y[j])
                j += 1
        if merged == sorted(merged):
            print("Yes")
        else:
            print("No")
'''


from math import *
t = int(input())
for y in range(t):
	n = int(input())
	a = list(map(int,input().split()))
	b = list(map(int,input().split()))
	if(a == sorted(a)):
		print("Yes")
		continue
	o = b.count(1)
	z = b.count(0)
	if(o > 0 and z > 0):
		print("Yes")
	else:
		print("No")

from sys import *


def solve(b):
    c1, c2 = 0, 0
    for el in b:
        if(el == 1):
            c1 += 1
        else:
            c2 += 1
    if(c1 == 0 or c2 == 0):
        print('No')
    else:
        print('Yes')
    pass


test = 1
test = int(input())
for t in range(0, test):
    # brr = [list(map(int,input().split())) for i in range(rows)]              # 2D array row-wise input
    n = int(input())
    # n, x = list(map(int, input().split()))
    brr = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    if(brr==sorted(brr)):
        print('Yes')
    else:
        ans = solve(arr)


'''
rows, cols = (5, 5)
arr = [[0]*cols for j in range(rows)]                                         # 2D array initialization
b=input().split()                                                             # list created by spliting about spaces
brr = [[int(b[cols*i+j]) for j in range(cols)] for i in range(rows)]          # 2D array Linear Input
rows,cols=len(brr),len(brr[0])                                                # no of rows/cols for 2D array
arr.sort(key = lambda x : x[1])                                               # sort list of tuples by 2nd element, Default priority - 1st Element then 2nd Element
s=set()                                                                       # empty set
a=maxsize                                                                     # initializing infinity
b=-maxsize                                                                    # initializing -infinity
mapped=list(map(function,input))                                              # to apply function to list element-wise
try:                                                                          # Error handling
    #code 1
except:                                                                       # ex. to stop at EOF
    #code 2 , if error occurs
'''