#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q; cin >> Q; while(Q--){ int n, m; cin >> n >> m; vector> a(m); for(int i = 0; i < m; i++) cin >> a[i].first; for(int i = 0; i < m; i++) cin >> a[i].second; sort(a.begin(), a.end()); bool flg = true; for(int i = 0; i + 1 < m; i++){ if(a[i].second > a[i + 1].second){ flg = false; break; } if(a[i].second == a[i + 1].second && (a[i].first != a[i + 1].first || a[i].first != a[i].second)){ flg = false; break; } } cout << (flg ? "Yes" : "No") << "\n"; } }