#include <bits/stdc++.h>
using namespace std;
int n, q[103], k, a[103][103], b[103][103], flag, woc, wq;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) {
    cin >> a[0][i];
    b[0][i] = a[0][i];
    if (a[0][i] != i) woc = 1;
  }
  if (woc == 0)
    cout << "NO";
  else {
    for (int i = 1; i <= k; i++) {
      int p = 0, f = 0;
      for (int j = 1; j <= n; j++) {
        a[i][j] = a[i - 1][q[j]];
        b[i][q[j]] = b[i - 1][j];
        if (a[i][j] != j) p = 1;
        if (b[i][q[j]] != q[j]) f = 1;
      }
      if ((p == 0 || f == 0) && (k - i) % 2 == 0) {
        if (p == 0 && f == 0 && i == 1 && i < k)
          cout << "NO";
        else
          cout << "YES";
        flag = 1;
        break;
      }
    }
    if (flag == 0) cout << "NO";
  }
  return 0;
}
