#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, q[maxn], s[maxn], k, p[maxn], r[maxn], x, t[maxn], cnt;
bool flg, khas;
inline void bld() {
  for (int i = 0; i < n; i++) p[i] = i;
}
inline void o(int* a) {
  for (int i = 0; i < n; i++) t[i] = p[a[i]];
  for (int i = 0; i < n; i++) p[i] = t[i];
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
    r[q[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s[i]--;
    if (s[i] == i) x++;
  }
  if (x == n) {
    cout << "NO";
    return 0;
  }
  bld();
  while (1) {
    cnt++;
    if (cnt > k) break;
    x = 0;
    o(q);
    for (int i = 0; i < n; i++) {
      if (p[i] == s[i]) x++;
    }
    if (x == n) {
      flg = 1;
      break;
    }
    x = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] == i) x++;
    }
    if (x == n) break;
  }
  if (flg && (cnt & 1) == (k & 1)) {
    if (cnt == 1 && k > 1)
      khas = 1;
    else {
      cout << "YES";
      return 0;
    }
  }
  flg = 0;
  cnt = 0;
  bld();
  while (1) {
    cnt++;
    if (cnt > k) break;
    x = 0;
    o(r);
    for (int i = 0; i < n; i++) {
      if (p[i] == s[i]) x++;
    }
    if (x == n) {
      flg = 1;
      break;
    }
    x = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] == i) x++;
    }
    if (x == n) break;
  }
  if (flg && (cnt & 1) == (k & 1)) {
    if (cnt == 1 && k > 1 && khas) {
      cout << "NO";
      return 0;
    }
    cout << "YES";
    return 0;
  }
  if (khas) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
