#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  cout << "x= " << x << endl;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  cout << "res" << res << endl;
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p) % p;
}
long long int nCrModPFermat(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    int zeroes = 0, ones = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
    }
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      if (x)
        ones++;
      else
        zeroes++;
    }
    bool f = 1;
    sort(a, a + n);
    if (ones == n || zeroes == n) {
      for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
          cout << "No" << endl;
          f = 0;
          break;
        }
      }
      if (f) {
        cout << "Yes\n";
      }
    } else {
      cout << "Yes\n";
    }
  }
}
