#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int q[110], q1[110], s[110], a[110], a1[110];
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) cin >> s[i];
  {
    bool f = true;
    for (int i = 1; i <= n; i++)
      if (s[i] != i) {
        f = false;
        break;
      }
    if (f) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) q1[q[i]] = i;
  bool obr = true;
  for (int i = 1; i <= n; i++)
    if (q1[i] != q[i]) obr = false;
  if (obr) {
    obr = true;
    for (int i = 1; i <= n; i++)
      if (q1[i] != s[i]) {
        obr = false;
        break;
      }
    if (obr && k == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) a[i] = i;
  bool flag = true;
  int p;
  for (p = 1; p <= k && flag; p++) {
    for (int i = 1; i <= n; i++) a1[i] = a[q[i]];
    for (int i = 1; i <= n; i++) a[i] = a1[i];
    flag = false;
    for (int i = 1; i <= n; i++)
      if (a[i] != s[i]) {
        flag = true;
        break;
      }
  }
  p--;
  if (!flag && ((k - p) % 2 == 0)) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) a[i] = i;
  flag = true;
  for (p = 1; p <= k && flag; p++) {
    for (int i = 1; i <= n; i++) a1[i] = a[q1[i]];
    for (int i = 1; i <= n; i++) a[i] = a1[i];
    flag = false;
    for (int i = 1; i <= n; i++)
      if (a[i] != s[i]) {
        flag = true;
        break;
      }
  }
  p--;
  if (flag) {
    cout << "NO" << endl;
    return 0;
  }
  if ((k - p) % 2 == 0) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}
