#include using namespace std; int main(){ int T; cin >> T; for (int i = 0; i < T; i++){ int N; cin >> N; vector A(N); for (int j = 0; j < N; j++){ cin >> A[j]; } vector B(N); for (int j = 0; j < N; j++){ cin >> B[j]; } vector P; P.push_back(0); for (int j = 1; j < N; j++){ if (B[j] != B[j - 1]){ P.push_back(j); } } P.push_back(N); int cnt = P.size(); bool ok = true; for (int j = 0; j < cnt - 1; j++){ bool ok2 = false; for (int k = P[j]; k < P[j + 1]; k++){ if (A[k] == B[P[j]]){ ok2 = true; } } if (!ok2){ ok = false; } } if (ok){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }