#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, k; cin >> n >> k; vector> s(k), t(k); rep(i, n) { string x; cin >> x; s[i % k].push_back(x); } rep(i, n) { string x; cin >> x; t[i % k].push_back(x); } rep(i, k) { sort(s[i].begin(), s[i].end()); sort(t[i].begin(), t[i].end()); if (s[i] != t[i]) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }