#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int q[105], s[105], a[105], tmp[105];
bool ck() {
  for (int i = 1; i <= n; i++)
    if (a[i] != s[i]) return 0;
  return 1;
}
bool cc(int a) { return k >= a && (k - a) % 2 == 0; }
bool ckl() {
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    scanf("%d", q + i + 1);
    a[i + 1] = i + 1;
  }
  for (int(i) = 0; (i) < (int)(n); (i)++) scanf("%d", s + i + 1);
  int up, down, j;
  for (j = 0, down = 0; j <= k; j++, down++) {
    if (ck()) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      tmp[i] = a[q[i]];
    }
    for (int i = 1; i <= n; i++) a[i] = tmp[i];
  }
  for (int i = 1; i <= n; i++) a[i] = i;
  for (j = 0, up = 0; j <= k; j++, up++) {
    if (ck()) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      tmp[q[i]] = a[i];
    }
    for (int i = 1; i <= n; i++) a[i] = tmp[i];
  }
  if (up == 0)
    puts("NO");
  else if (up == 1 && down == 1) {
    puts(k == 1 ? "YES" : "NO");
  } else {
    puts(cc(up) || cc(down) ? "YES" : "NO");
  }
  return 0;
}
