#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const long long MOD = 1e9 + 7;
const double eps = 1e-9;
int n, k, q[N], qv[N], s[N];
vector<int> p;
vector<int> apply(vector<int> &a, int *p) {
  vector<int> b(n + 1);
  for (int i = 1; i <= n; i++) b[i] = a[p[i]];
  return b;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", q + i);
  bool f = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", s + i);
    if (i && s[i] < s[i - 1]) f = 0;
  }
  if (f) {
    puts("NO");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int j = 1;
    while (j <= n && q[j] != i) j++;
    qv[i] = j;
  }
  bool eq = 1;
  for (int i = 1; i <= n; i++)
    if (q[i] != qv[i]) {
      eq = 0;
      break;
    }
  p.resize(n + 1);
  for (int it = 0; it < 2; it++) {
    for (int i = 1; i <= n; i++) p[i] = i;
    for (int i = 1; i <= k; i++) {
      p = apply(p, q);
      f = 1;
      for (int j = 1; j <= n; j++)
        if (p[j] != s[j]) {
          f = 0;
          break;
        }
      if (f) {
        if ((!eq && (k - i) % 2 == 0) || (eq && i == k)) {
          puts("YES");
          return 0;
        }
        break;
      }
    }
    swap(q, qv);
  }
  puts("NO");
  return 0;
}
