#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, k;
int pp[2 * N][N];
int q[N];
int s[N];
void getinv(int a[N], int b[N]) {
  for (int i = 1; i <= n; ++i) {
    a[q[i]] = b[i];
  }
}
void get(int a[N], int b[N]) {
  for (int i = 1; i <= n; ++i) {
    a[i] = b[q[i]];
  }
}
int check(int a[N], int b[N]) {
  for (int i = 1; i <= n; ++i) {
    if (a[i] != b[i]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", q + i);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", s + i);
  }
  for (int i = 1; i <= n; ++i) {
    pp[0 + N][i] = i;
  }
  for (int i = 1; i <= k; ++i) {
    get(pp[i + N], pp[i - 1 + N]);
    getinv(pp[N - i], pp[N - i + 1]);
  }
  if (check(pp[0 + N], s)) {
    puts("NO");
    return 0;
  }
  int who = -1;
  for (int i = k & 1; i <= k; i += 2) {
    if (check(pp[i + N], s)) {
      who = i;
      break;
    }
  }
  if (who == 0) {
    puts("NO");
    return 0;
  }
  if (who == 1) {
    if (k == 1 || !check(pp[N - 1], s)) {
      puts("YES");
      return 0;
    }
  }
  if (who > 1) {
    puts("YES");
    return 0;
  }
  who = -1;
  for (int i = k & 1; i <= k; i += 2) {
    if (check(pp[N - i], s)) {
      who = i;
      break;
    }
  }
  if (who == 0) {
    puts("NO");
    return 0;
  }
  if (who == 1) {
    if (k == 1 || !check(pp[N + 1], s)) {
      puts("YES");
      return 0;
    }
  }
  if (who > 1) {
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}
