#include <bits/stdc++.h>
using namespace std;
const int MAXN = 123;
const int MAXK = 123;
int q[MAXN], t[MAXN];
int a[MAXN], lst[MAXN];
const char *YES = "YES", *NO = "NO";
int main() {
  int n, k;
  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", t + i);
  bool zero = 1;
  for (int i = 1; i <= n; i++)
    if (t[i] != i) {
      zero = 0;
      break;
    }
  if (zero) {
    puts(NO);
    return 0;
  }
  int left = MAXK, right = MAXK;
  {
    for (int i = 1; i <= n; i++) a[i] = i;
    for (int time = 1; time <= k; time++) {
      for (int i = 1; i <= n; i++) lst[i] = a[i];
      for (int i = 1; i <= n; i++) a[i] = lst[q[i]];
      bool done = 1;
      for (int i = 1; i <= n; i++)
        if (a[i] != t[i]) {
          done = 0;
          break;
        }
      if (done) {
        right = time;
        break;
      }
    }
  }
  {
    for (int i = 1; i <= n; i++) a[i] = i;
    for (int time = 1; time <= k; time++) {
      for (int i = 1; i <= n; i++) lst[i] = a[i];
      for (int i = 1; i <= n; i++) a[q[i]] = lst[i];
      bool done = 1;
      for (int i = 1; i <= n; i++)
        if (a[i] != t[i]) {
          done = 0;
          break;
        }
      if (done) {
        left = time;
        break;
      }
    }
  }
  (void)0;
  if (left == 1 && right == 1)
    puts(k == 1 ? YES : NO);
  else {
    bool yes = 0;
    if (left <= k && left % 2 == k % 2) yes = 1;
    if (right <= k && right % 2 == k % 2) yes = 1;
    puts(yes ? YES : NO);
  }
  return 0;
}
