#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) {
    return a.first > b.first;
  }
  return a.first < b.first;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<int> a(n, 0);
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    int a1 = 0;
    int a2 = 0;
    for (int i = 0; i < n; i++) {
      if (b[i] == 0) {
        a1++;
      } else
        a2++;
    }
    string ans = "Yes";
    if (a1 == 0 || a2 == 0) {
      vector<int> c(n, 0);
      for (int i = 0; i < n; i++) c[i] = a[i];
      sort(c.begin(), c.end());
      for (int i = 0; i < n; i++) {
        if (a[i] != c[i]) {
          ans = "No";
          break;
        }
      }
    }
    cout << ans << endl;
  }
}
