#include <bits/stdc++.h>
using namespace std;
namespace std {
template <>
struct hash<pair<int, int>> {
  size_t operator()(const pair<int, int> &x) const {
    long long P = 38923, Q = 109797901;
    return (size_t)((x.first * P + x.second) % Q);
  }
};
};  // namespace std
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
void print(T t) {
  cout << t << endl;
}
template <typename T, typename... Args>
void print(T t, Args... args) {
  cout << t << " ";
  print(args...);
}
const int MAXN = 105;
int n, k, p[MAXN], q[MAXN], s[MAXN], a[MAXN], b[MAXN], t = -1;
vector<vector<int>> cycle;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1) {
    cin >> p[i];
    p[i]--;
    q[p[i]] = i;
  }
  for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1) {
    cin >> s[i];
    s[i]--;
  }
  {
    bool same = true;
    for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1)
      if (s[i] != i) same = false;
    if (same) {
      cout << "NO\n";
      return 0;
    }
  }
  for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1) a[i] = i;
  t = -1;
  for (int i = min((int)0, (int)k); i < max((int)0, (int)k); i += 1) {
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1) {
      b[p[j]] = a[j];
    }
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1)
      a[j] = b[j];
    bool same = true;
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1)
      if (a[j] != s[j]) same = false;
    if (same) {
      t = i + 1;
      break;
    }
  }
  bool same = true;
  for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1)
    if (p[i] != q[i]) same = false;
  if (same && t == 1) {
    if (k == 1) {
      cout << "YES\n";
      return 0;
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  if (t >= 0 && ((k - t + 1) & 1)) {
    cout << "YES\n";
    return 0;
  }
  for (int i = min((int)0, (int)n); i < max((int)0, (int)n); i += 1) a[i] = i;
  t = -1;
  for (int i = min((int)0, (int)k); i < max((int)0, (int)k); i += 1) {
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1) {
      b[q[j]] = a[j];
    }
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1)
      a[j] = b[j];
    same = true;
    for (int j = min((int)0, (int)n); j < max((int)0, (int)n); j += 1)
      if (a[j] != s[j]) same = false;
    if (same) {
      t = i + 1;
      break;
    }
  }
  if (t >= 0 && ((k - t + 1) & 1)) {
    cout << "YES\n";
    return 0;
  }
  cout << "NO\n";
  return 0;
}
