#include <bits/stdc++.h>
using namespace std;
int tmp[111];
void permuteArr(int *arr1, int *per, int sz) {
  for (int i = 0; i < sz; i++) tmp[per[i] - 1] = arr1[i];
  for (int i = 0; i < sz; i++) arr1[i] = tmp[i];
}
bool isSame(int *arr1, int *arr2, int sz) {
  for (int i = 0; i < sz; i++)
    if (arr1[i] != arr2[i]) return 0;
  return 1;
}
void printArr(int *arr, int sz) {
  for (int i = 0; i < sz; i++) cout << arr[i] << " ";
  cout << "\n";
}
int main() {
  int n, k, s[111], q[111], p[111], t1[111], t2[111], distPS = 111,
                                                      distSP = 111;
  bool can = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> q[i];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) p[i] = i + 1;
  for (int i = 0; i < n; i++) {
    t1[i] = p[i];
    t2[i] = s[i];
  }
  for (int i = 0; i <= k; i++) {
    if (isSame(t1, s, n) && distPS > i) distPS = i;
    if (isSame(t2, p, n) && distSP > i) distSP = i;
    permuteArr(t1, q, n);
    permuteArr(t2, q, n);
  }
  if (distSP == k || distPS == k) {
    can = 1;
  }
  if (distSP > 1 && distPS <= k && (k - distPS) % 2 == 0) {
    can = 1;
  }
  if (distPS > 1 && distSP <= k && (k - distSP) % 2 == 0) {
    can = 1;
  }
  if (distPS > 1 && distPS <= k && (k - distPS) % 2 == 0) {
    can = 1;
  }
  if (distSP > 1 && distSP <= k && (k - distSP) % 2 == 0) {
    can = 1;
  }
  if (can == 0)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
