#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> q, s, p;
vector<int> Pos(vector<int>& P) {
  vector<int> ret;
  ret.resize(N);
  for (int i = 0; i < N; i++) {
    ret[i] = P[q[i]];
  }
  return ret;
}
vector<int> Neg(vector<int>& P) {
  vector<int> ret;
  ret.resize(N);
  for (int i = 0; i < N; i++) {
    ret[q[i]] = P[i];
  }
  return ret;
}
bool operator==(vector<int>& a1, vector<int>& a2) {
  for (int i = 0; i < N; i++) {
    if (a1[i] != a2[i]) return false;
  }
  return true;
}
int main() {
  scanf("%d", &N);
  scanf("%d", &K);
  int a;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    q.push_back(a - 1);
    p.push_back(i);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    s.push_back(a - 1);
  }
  if (1 == 1) {
    vector<int> pos = Pos(p);
    vector<int> neg = Neg(p);
    if (pos == neg) {
      if (K != 1) {
        printf("NO\n");
        return 0;
      }
    }
    if (s == p) {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = 0; i < K; i++) {
    p = Pos(p);
    if ((K - i) % 2 == 1 && p == s) {
      printf("YES\n");
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    p[i] = i;
  }
  for (int i = 0; i < K; i++) {
    p = Neg(p);
    if ((K - i) % 2 == 1 && p == s) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
