#include <bits/stdc++.h>
int main() {
  int n, k, q[101], s[101], p[101], pp[101], fp = -1, fr = -1, op[101],
                                             opp[101];
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &q[i]);
    pp[i] = p[i] = i;
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
  for (int i = 0; i <= k; ++i) {
    int j = 1;
    memcpy(op, p, sizeof p);
    memcpy(opp, pp, sizeof pp);
    if (fp < 0) {
      for (; j <= n && p[j] == s[j]; ++j)
        ;
      if (j > n) fp = i;
    }
    if (fr < 0) {
      for (j = 1; j <= n && pp[j] == s[j]; ++j)
        ;
      if (j > n) fr = i;
    }
    for (j = 1; j <= n; ++j) {
      p[j] = op[q[j]];
      pp[q[j]] = opp[j];
    }
  }
  if (fr == k || fp == k ||
      (fr > 0 && fr < k && (fr > 1 || fp > 1 || fp < 0) &&
       (fr & 1) == (k & 1)) ||
      (fp > 0 && fp < k && (fr > 1 || fp > 1 || fr < 0) && (fp & 1) == (k & 1)))
    printf("YES");
  else
    printf("NO");
  return 0;
}
