#include <bits/stdc++.h>
using namespace std;
int q[100];
int p[100];
int op[100];
int s[100];
int n, k;
bool check(int *a, int *b) {
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) return false;
  return true;
}
void head() {
  for (int i = 0; i < n; i++) op[i] = p[i];
  for (int i = 0; i < n; i++) p[i] = op[q[i] - 1];
}
void tail() {
  for (int i = 0; i < n; i++) op[i] = p[i];
  for (int i = 0; i < n; i++) p[q[i] - 1] = op[i];
}
int main() {
  ifstream inf("in.txt");
  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;
  if (check(p, s)) {
    cout << "NO" << endl;
    return 0;
  }
  for (int l = 0; l < k; l++) {
    head();
    if ((l + 1) % 2 == k % 2 && check(p, s))
      if (l == 0) {
        tail();
        tail();
        if (!check(p, s) || k == 1) {
          cout << "YES" << endl;
          return 0;
        } else {
          cout << "NO" << endl;
          return 0;
        }
      } else {
        cout << "YES" << endl;
        return 0;
      }
  }
  for (int i = 0; i < n; i++) p[i] = i + 1;
  for (int l = 0; l < k; l++) {
    tail();
    if ((l + 1) % 2 == k % 2 && check(p, s))
      if (l == 0) {
        head();
        head();
        if (!check(p, s) || k == 1) {
          cout << "YES" << endl;
          return 0;
        } else {
          cout << "NO" << endl;
          return 0;
        }
      } else {
        cout << "YES" << endl;
        return 0;
      }
  }
  cout << "NO" << endl;
}
