#include <bits/stdc++.h>
using namespace std;
long long int p[105], q[105], s[105], pnew[105], t[105], tnew[105], invq[105];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k, cnt, qi = 0, pos = 0, neg = 0;
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) {
    cin >> q[i];
    invq[q[i]] = i;
  }
  for (long long int i = 1; i <= n; i++) {
    if (q[i] == invq[i]) qi++;
  }
  for (long long int i = 1; i <= n; i++) cin >> s[i];
  for (long long int i = 1; i <= n; i++) p[i] = i, t[i] = i;
  cnt = 0;
  for (long long int i = 1; i <= n; i++) {
    if (p[i] == s[i]) cnt++;
  }
  if (cnt == n) {
    cout << "NO" << endl;
    return 0;
  }
  for (long long int i = 1; i <= k; i++) {
    for (long long int j = 1; j <= n; j++) {
      pnew[j] = p[q[j]];
    }
    cnt = 0;
    for (long long int j = 1; j <= n; j++) {
      if (pnew[j] == s[j]) cnt++;
    }
    if (cnt == n) {
      if ((k - i) % 2 == 0) {
        if (qi == n && k == 1)
          cout << "YES" << endl;
        else if (qi != n)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
    }
    for (long long int j = 1; j <= n; j++) p[j] = pnew[j];
  }
  for (long long int i = 1; i <= k; i++) {
    for (long long int j = 1; j <= n; j++) {
      tnew[q[j]] = t[j];
    }
    cnt = 0;
    for (long long int j = 1; j <= n; j++) {
      if (tnew[j] == s[j]) cnt++;
    }
    if (cnt == n) {
      if ((k - i) % 2 == 0) {
        if (qi == n && k == 1)
          cout << "YES" << endl;
        else if (qi != n)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
    }
    for (long long int j = 1; j <= n; j++) t[j] = tnew[j];
  }
  cout << "NO" << endl;
}
