#include using namespace std; using ll = long long; using P = pair; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() int main(){ int t; cin >> t; int MAX_N = 100001; vector PNJudge(MAX_N,true); PNJudge[1] = false; for(int i=2;i> n; vector a(n), b(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; bool ans = (a[0]==b[0]); multiset as, bs; rep(i,n){ if(!ans) break; if(!i) continue; if(PNJudge[i+1] && (i+1)*2 > n) ans = (a[i] == b[i]); else{ as.insert(a[i]); bs.insert(b[i]); } } if(ans) ans = (as == bs); if(ans) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }