#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, k, ok, da;
int q[N], s[N];
int niz[N], pom[N];
int main(void) {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &q[i]);
    --q[i];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &s[i]);
    --s[i];
  }
  ok = 1;
  for (int i = 0; i < n; ++i)
    if (s[i] != i) ok = 0;
  if (k != 1) {
    da = 1;
    for (int i = 0; i < n; ++i) niz[i] = i;
    for (int i = 0; i < n; ++i) pom[i] = niz[q[i]];
    for (int i = 0; i < n; ++i) niz[i] = pom[i];
    for (int i = 0; i < n; ++i)
      if (niz[i] != s[i]) da = 0;
    for (int i = 0; i < n; ++i) niz[i] = i;
    for (int i = 0; i < n; ++i) pom[q[i]] = niz[i];
    for (int i = 0; i < n; ++i) niz[i] = pom[i];
    for (int i = 0; i < n; ++i)
      if (niz[i] != s[i]) da = 0;
  }
  if (ok || da) {
    printf("NO\n");
    return 0;
  }
  ok = 0;
  for (int i = 0; i < n; ++i) niz[i] = i;
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < n; ++j) pom[j] = niz[q[j]];
    for (int j = 0; j < n; ++j) niz[j] = pom[j];
    da = 1;
    for (int j = 0; j < n; ++j)
      if (niz[j] != s[j]) da = 0;
    if (da) {
      if ((k - i) & 1) ok = 1;
      break;
    }
  }
  for (int i = 0; i < n; ++i) niz[i] = i;
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < n; ++j) pom[q[j]] = niz[j];
    for (int j = 0; j < n; ++j) niz[j] = pom[j];
    da = 1;
    for (int j = 0; j < n; ++j)
      if (niz[j] != s[j]) da = 0;
    if (da) {
      if ((k - i) & 1) ok = 1;
      break;
    }
  }
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
