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.
/*==============================================
Author      : Shadman Shariar                 ||
Email       : shadman.shariar@northsouth.edu  ||
University  : North South University (NSU)    ||
Facebook    : shadman.shahriar.007            ||
==============================================*/
import java.io.*;
import java.util.*;
//import java.math.BigInteger;
//import java.text.DecimalFormat;
public class Main {
public static Main obj = new Main();
public static int [] dx = {-1, 1, 0, 0, -1, -1, 1, 1};
public static int [] dy = {0, 0, -1, 1, -1, 1, -1, 1};
//public static FastReader fr = new FastReader();
public static Scanner input = new Scanner(System.in);
//public static PrintWriter pw = new PrintWriter(System.out);
//public static DecimalFormat df = new DecimalFormat(".000000000");
//public static BufferedReader br = new BufferedReader
//(new InputStreamReader(System.in));
public static void main (String[] args) throws Exception {
Scanner input = new Scanner (System.in);
//BigInteger bi = new BigInteger("000");
//StringBuilder sb = new StringBuilder();
//StringBuffer sbf = new StringBuffer();
//StringTokenizer st = new StringTokenizer("String","Split");
//Vector vc = new Vector();
//ArrayList<Integer> al= new ArrayList<Integer>();
//LinkedList<Integer> ll= new LinkedList<Integer>();
//Stack <Integer> stk = new Stack <Integer>();
//Queue <Integer> q = new LinkedList<Integer>();
//ArrayDeque<Integer> ad = new ArrayDeque<Integer>();
//PriorityQueue <Integer> pq = new PriorityQueue<Integer>();
//PriorityQueue <Integer> pqr = new PriorityQueue<Integer>(Comparator.reverseOrder());
//HashSet<Integer> hs = new HashSet<Integer>();
//LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
//TreeSet<Integer> ts = new TreeSet<Integer>();
//TreeSet<Integer> tsr = new TreeSet<Integer>(Comparator.reverseOrder());
//HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
//LinkedHashMap<Integer,Integer> lhm = new LinkedHashMap<Integer,Integer>();
//TreeMap<Integer,Integer> tm = new TreeMap<Integer,Integer>();
//TreeMap<Integer,Integer> tmr = new TreeMap<Integer,Integer>(Comparator.reverseOrder());
//LinkedList<Integer> adj[] = new LinkedList[size];

//-----------------CODE STARTS FROM HERE------------------//

int t = input.nextInt();

for (int i = 0; i < t; i++) {
	
	int n = input.nextInt();
	
	int [] arr = new int [n];
	
	int [] brr = new int [n];
	
	boolean bo = true ;
	
	
	for (int j = 0; j < brr.length; j++) {
		arr[j] = input.nextInt();
	}
	int o = 0 , z =0 ;
	for (int j = 0; j < brr.length; j++) {
		brr[j] = input.nextInt();
		if(brr[j]==0) {
			z++;
		}
		else {
			o++;
		}
		
	}
	
	
	
	for (int j = 1; j < brr.length; j++) {
	
	if(arr[j-1]>arr[j]) {
		
		bo = false ;
		
		break;
		
	}
}

	if((bo==false)&&(o==0||z==0)) {
		System.out.println("NO");
	}
	else {
		System.out.println("YES");
	}
	
	
	
}



//---------------------CODE ENDS HERE---------------------//

        //pw.close();
        input.close();
		System.exit(0);
}

   public static class Node {
		Node left, right;
		int data;
		public Node(int data) {
			this.data = data;
		}
   }

   public static Node createTree() {
	Node root = null;
	System.out.println("Enter data: ");
	int data = input.nextInt();
	if(data == -1) return null;
	root = new Node(data);
	System.out.println("Enter left for " + data);
	root.left = createTree();
	System.out.println("Enter right for "+ data);
	root.right = createTree();
	return root;
   }

   public static void inOrder(Node root) {
	if(root == null) return;
	inOrder(root.left);
	System.out.print(root.data+" ");
	inOrder(root.right);
   }

   public static long gcd(long a, long b) {
	   if (a == 0)
		   return b;
	   return gcd(b % a, a);
   }

   public static long lcm(long a, long b) {
	   return (a / gcd(a, b)) * b;
   }

   public static long nCr(long n, long r)
   {
       return factorial(n) / (factorial(r) *
                  factorial(n - r));
   }

   public static long nPr(long n, long r)
   {
    return factorial(n) / factorial(n - r);
   }

   public static long countsubstring(String str)
   {
    long n = str.length();
    return n * (n + 1) / 2;
   }

   public static boolean ispalindrome(String str)
   {
    int i = 0, j = str.length() - 1;
    while (i < j) {
        if (str.charAt(i) != str.charAt(j))
            return false;
        i++;
        j--;
    }
    return true;
   }

   public static boolean perfectsquare(long x)
   {
    if (x >= 0) {
        long sr = (long)(Math.sqrt(x));
        return ((sr * sr) == x);
    }
    return false;
   }

   public static boolean perfectcube(long N)
   {
    int cube; int c = 0;
    for (int i = 0; i <= N; i++) {
        cube = i * i * i;
        if (cube == N) {
           
            c=1; break;
        }
        else if (cube > N) {
          
           c=0 ; break ;
        }
    }
	  if (c==1)return true;
	  else return false;
   }

   public static int divcount(int n)
   {
       boolean hash[] = new boolean[n + 1];
       Arrays.fill(hash, true);
       for (int p = 2; p * p < n; p++)
           if (hash[p] == true)
               for (int i = p * 2; i < n; i += p)
                   hash[i] = false;
       int total = 1;
       for (int p = 2; p <= n; p++) 
       {
           if (hash[p])
           {
               int count = 0;
               if (n % p == 0) 
               {
                   while (n % p == 0) 
                   {
                       n = n / p;
                       count++;
                   }
                   total = total * (count + 1);
               }
           }
       }
       return total;
   }

   public static void printdiv(int n)
  {
      for (int i=1; i<=Math.sqrt(n); i++)
      {
          if (n%i==0)
          {
              if (n/i == i)
                  System.out.print(" "+ i);
    
              else
                  System.out.print(i+" " + n/i + " " );
          }
      }
  }

   public static boolean[] sieveOfEratosthenes(int n)
   {
    boolean prime[] = new boolean[n + 1];
    for (int i = 0; i <= n; i++)
        prime[i] = true;
 
    for (int p = 2; p * p <= n; p++)
    {
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    prime[1]=false;
    return prime;
   }

   public static int removeduplicateelements(int arr[], int n){ 
		Arrays.sort(arr);
        if (n==0 || n==1){  
            return n;  
        }  
        int[] temp = new int[n];  
        int j = 0;  
        for (int i=0; i<n-1; i++){  
            if (arr[i] != arr[i+1]){  
                temp[j++] = arr[i];  
            }  
         }  
        temp[j++] = arr[n-1];      
        for (int i=0; i<j; i++){  
            arr[i] = temp[i];  
        }  
        return j;  
    }  

   public static int fibon(int n) {
 
		if (n <= 1) {
 
			return n;
		}
		int[] array = new int[n + 1];
		array[0] = 0;
		array[1] = 1;
		for (int i = 2; i <= n; i++) {
			array[i] = array[i - 2] + array[i - 1];
		}
 
		return array[n];
 
	}

   public static long sumofdigits(long n) {
		long sum = 0;
 
		while (n != 0) {
			sum = sum + n % 10;
			n = n / 10;
		}
 
		return sum;
	}

   public static int reversedigits(int num) {
		int rev_num = 0;
		while (num > 0) {
			rev_num = rev_num * 10 + num % 10;
			num = num / 10;
		}
		return rev_num;
	}

   public static int binarysearch(int arr[], int l, int r, int x) {
 
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarysearch(arr, l, mid - 1, x);
			return binarysearch(arr, mid + 1, r, x);
		}
		return -1;
	}

   public static void rangeofprimenumber(int a, int b) {
		int i, j, flag;
		for (i = a; i <= b; i++) {
			if (i == 1 || i == 0)
				continue;
			flag = 1;
			for (j = 2; j <= i / 2; ++j) {
				if (i % j == 0) {
					flag = 0;
					break;
				}
			}
			if (flag == 1)
				System.out.println(i);
		}
	}

   public static boolean isprime(long n) {
		if (n <= 1)
			return false;
		else if (n == 2)
			return true;
		else if (n % 2 == 0)
			return false;
		for (long i = 3; i <= Math.sqrt(n); i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}

   public static long factorial(long n) {
		return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
	}

   public static int[] reversearrayinrange(int arr[], int start, int end) {
		int temp;
 
		while (start < end) {
			temp = arr[start];
			arr[start] = arr[end];
			arr[end] = temp;
			start++;
			end--;
		}
	  return arr;
	}

   public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}