#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[200];
int tmp[200];
int q[200];
int s[200];
void first() {
  for (int i = 1; i <= n; i++) tmp[i] = p[q[i]];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
void second() {
  for (int i = 1; i <= n; i++) tmp[q[i]] = p[i];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
bool ok() {
  for (int i = 1; i <= n; i++)
    if (s[i] != p[i]) return 0;
  return 1;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) cin >> s[i];
  bool f_ok = 0, s_ok = 0;
  for (int i = 1; i <= n; i++) p[i] = i;
  if (ok()) {
    cout << "NO";
    return 0;
  }
  first();
  f_ok = ok();
  second();
  second();
  s_ok = ok();
  if (f_ok && s_ok) {
    if (k == 1)
      cout << "YES";
    else
      cout << "NO";
    return 0;
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    first();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    second();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  cout << "NO";
}
