#include using namespace std; using ll=long long; using ld=long double; const ll ILL=2167167167167167167; const int INF=2100000000; #define ALL(a) (a).begin(),(a).end() #define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define repr(i,a,b) for (int i=(int)(a);i>=(int)(b);i--) template using _pq = priority_queue, greater>; template ll LB(vector &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();} template ll UB(vector &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();} template void So(vector &v) {sort(v.begin(),v.end());} template void Sore(vector &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});} template T vec_min(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;} template T vec_max(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;} template T vec_sum(vector &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;} template void vec_out(vector &a){for(auto &x:a) cout< bool chmin(T &a,T b){if(b bool chmax(T &a,T b){if(a> n >> k; vector s(n), t(n); rep(i, 0, n) cin >> s[i]; rep(i, 0, n) cin >> t[i]; vector> gs(k), gt(k); rep(i, 0, n) { gs[i % k].push_back(s[i]); gt[i % k].push_back(t[i]); } rep(r, 0, k) { sort(ALL(gs[r])); sort(ALL(gt[r])); if (gs[r] != gt[r]) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }