#include <bits/stdc++.h>
using namespace std;
int n, k;
struct seq {
  int a[105];
  int& operator[](int x) { return a[x]; }
  bool operator==(seq s) {
    for (int i = 0; i < n; i++)
      if (a[i] != s.a[i]) return 0;
    return 1;
  }
} q, p, inv, r;
seq perm(int k, seq p, seq s) {
  seq res;
  for (int a = 0; a < k; a++)
    for (int i = 0; i < n; i++) res[i] = p[s[i]];
  return res;
}
void print(seq s) {
  for (int i = 0; i < n; i++) cout << s[i] << " ";
  cout << '\n';
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
    inv[q[i]] = i;
  }
  for (int i = 0; i < n; i++) p[i] = i;
  for (int i = 0; i < n; i++) {
    cin >> r[i];
    r[i]--;
  }
  if (p == r) {
    cout << "NO";
    return 0;
  }
  seq f = p, b = p;
  int fi = -1, bi = -1;
  for (int i = 0; i < k; i++) {
    f = perm(1, f, q);
    if (f == r) {
      fi = i + 1;
      break;
    }
  }
  for (int i = 0; i < k; i++) {
    b = perm(1, b, inv);
    if (b == r) {
      bi = i + 1;
      break;
    }
  }
  if (k == 1) {
    if (perm(1, p, q) == r || perm(1, p, inv) == r)
      cout << "YES";
    else
      cout << "NO";
  } else {
    if (perm(1, p, q) == r && perm(1, p, inv) == r)
      cout << "NO";
    else if ((k % 2 == fi % 2 && fi >= 0) || (k % 2 == bi % 2 && bi >= 0))
      cout << "YES";
    else
      cout << "NO";
  }
}
