#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, flag = 0;
    cin >> n;
    int a[n];
    vector<int> v;
    int b[n];
    int c[2] = {0};
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      v.push_back(a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      c[b[i]] = 1;
    }
    if (c[0] == 0 || c[1] == 0) {
      sort(v.begin(), v.end());
    }
    for (int i = 0; i < n; i++) {
      if (v[i] != a[i]) {
        cout << "No" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "Yes" << endl;
    }
  }
}
