#include <bits/stdc++.h>
enum { MAXN = 102 };
int reverse[MAXN], target[MAXN], init[MAXN];
int n;
int eq(int *a, int *b) {
  int i;
  for (i = 1; i <= n; i++)
    if (a[i] != b[i]) return 0;
  return 1;
}
void proc(int *a, int *b) {
  int ans[MAXN], i;
  for (i = 1; i <= n; i++) {
    ans[i] = a[b[i]];
  }
  for (i = 1; i <= n; i++) a[i] = ans[i];
}
void print(int *a) {
  int i;
  for (i = 1; i <= n; i++) printf("%d ", a[i]);
  puts("");
}
int main(void) {
  int k, m1, m2, i;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d", init + i);
    reverse[init[i]] = i;
  }
  for (i = 1; i <= n; i++) scanf("%d", target + i);
  int natur[MAXN];
  for (i = 1; i <= n; i++) natur[i] = i;
  m1 = 0;
  m2 = 0;
  while (m1 < 1000 && !eq(natur, target)) {
    proc(natur, init);
    m1++;
  }
  if (!eq(natur, target)) m1 = -1;
  for (i = 1; i <= n; i++) natur[i] = i;
  while (m2 < 1000 && !eq(natur, target)) {
    proc(natur, reverse);
    m2++;
  }
  if (!eq(natur, target)) m2 = -1;
  char *ans = "NO";
  if (m1 == 1 && m2 == 1) {
    if (k == 1) ans = "YES";
  } else if (m1 == 1 || m2 == 1) {
    if (k % 2 == 1) ans = "YES";
  }
  if (m1 > 1 && (k - m1) >= 0 && (k - m1) % 2 == 0) ans = "YES";
  if (m2 > 1 && (k - m2) >= 0 && (k - m2) % 2 == 0) ans = "YES";
  puts(ans);
  return 0;
}
