#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> q, s, parent, pos, cpy;
int main() {
  cin >> n >> k;
  q.resize(n + 1), s.resize(n + 1), parent.resize(n + 1), pos.resize(n + 1),
      cpy.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) parent[q[i]] = i;
  bool op = false;
  for (int i = 1; i <= n; i++)
    if (s[i] != i) op = true;
  if (!op) return cout << "NO", 0;
  op = false;
  for (int i = 1; i <= n; i++)
    if (parent[i] != q[i]) op = true;
  if (!op && k > 1) return cout << "NO", 0;
  bool ans = false;
  for (int i = 1; i <= n; i++) pos[i] = i;
  int tt = 0;
  while (pos != s) {
    tt++;
    for (int i = 1; i <= n; i++) cpy[i] = pos[q[i]];
    for (int i = 1; i <= n; i++) pos[i] = cpy[i];
    if (tt > k) break;
  }
  if (tt <= k && tt % 2 == k % 2) {
    ans = true;
  }
  for (int i = 1; i <= n; i++) pos[i] = i;
  tt = 0;
  while (pos != s) {
    tt++;
    for (int i = 1; i <= n; i++) cpy[i] = pos[parent[i]];
    for (int i = 1; i <= n; i++) pos[i] = cpy[i];
    if (tt > k) break;
  }
  if (tt <= k && tt % 2 == k % 2) ans = true;
  cout << ((ans) ? "YES" : "NO");
  return 0;
}
