#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
const int MAXN = 110;
int q[MAXN];
int val[MAXN], N, K;
int target[MAXN];
int tmp[MAXN];
int main() {
  while (scanf("%d%d", &N, &K) != EOF) {
    for (int i = 1; i <= N; i++) scanf("%d", &q[i]);
    for (int i = 1; i <= N; i++) {
      val[i] = i;
      scanf("%d", &target[i]);
    }
    int stepa = 0;
    while (stepa <= K) {
      bool flag = false;
      for (int i = 1; i <= N; i++)
        if (val[i] != target[i]) flag = true;
      if (!flag) break;
      for (int i = 1; i <= N; i++) tmp[i] = val[i];
      for (int i = 1; i <= N; i++) val[i] = tmp[q[i]];
      stepa++;
    }
    int stepb = 0;
    for (int i = 1; i <= N; i++) val[i] = i;
    while (stepb <= K) {
      bool flag = false;
      for (int i = 1; i <= N; i++)
        if (val[i] != target[i]) flag = true;
      if (!flag) break;
      for (int i = 1; i <= N; i++) tmp[i] = val[i];
      for (int i = 1; i <= N; i++) val[q[i]] = tmp[i];
      stepb++;
    }
    if (stepa == 0 && stepb == 0)
      puts("NO");
    else if ((stepa == 1 || stepb == 1) && K == 1)
      puts("YES");
    else if (stepa > K && stepb > K)
      puts("NO");
    else if (stepa == 1 && stepb == 1)
      puts("NO");
    else if ((K + stepa + 1) % 2 == 1 || (K + stepb + 1) % 2 == 1)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
