#include <bits/stdc++.h>
using namespace std;
int i, j, n, m;
int d = 0, l = 0, k = 0;
double x = 0, y = 0, X0, Y0, X1, Y1, X2, Y2;
int a[110] = {0};
int b[110] = {0};
int c[110] = {0};
int temp[110] = {0};
int temp2[110] = {0};
void transition(int key) {
  memcpy(temp, a, n * sizeof(int));
  if (key == 1) {
    for (int i = 0; i < n; i++) a[i] = temp[b[i] - 1];
  } else {
    for (int i = 0; i < n; i++) a[b[i] - 1] = temp[i];
  }
}
int cmp(int* a, int* b, int n) {
  int res = 0;
  for (int i = 0; i < n; i++) res += (a[i] - b[i]) != 0;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> b[i];
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) a[i] = i + 1;
  memcpy(temp2, a, n * sizeof(int));
  if (cmp(a, c, n) == 0)
    cout << "NO";
  else {
    for (i = 0; i < k && cmp(a, c, n) != 0; i++) {
      transition(1);
    }
    if (cmp(a, c, n) == 0 && (k - i) % 2 == 0) {
      if (i == 1 && k != 1) {
        memcpy(a, temp2, n * sizeof(int));
        transition(0);
        if (cmp(a, c, n) == 0) {
          cout << "NO";
          return 0;
        }
      }
      cout << "YES";
      return 0;
    }
    memcpy(a, temp2, n * sizeof(int));
    for (i = 0; i < k && cmp(a, c, n) != 0; i++) {
      transition(0);
    }
    if (cmp(a, c, n) == 0 && (k - i) % 2 == 0) {
      cout << "YES";
      return 0;
    }
    cout << "NO";
  }
  return 0;
}
